gcc v3.0.1 vs gcc v2.95.3 -- KDE 2.2.1

Giorgos Keramidas charon at labs.gr
Sat Dec 1 21:20:13 EET 2001


On 2001-11-29 19:21:49, v13 at priest.com wrote:
>
> $ cat a.cc
> int main(char *p)
> {
> }
>
> void main(int n)
> {
> }

As baloume line numbers sto paradeigma sou:

     1	int main(char *p)
     2	{
     3	}
     4
     5	void main(int n)
     6	{
     7	}

> $ g++ a.cc
> a.cc:6: `main' must return `int'

Sthn line 6 to gcc blepei to opening brace apo mia function pou einai
dhlomenh san `void main (int)' kai jerei apo prohgoumenh emfanish ths
(auth sthn grammh 1-2) oti epistrefei (int).  Gi auto kai sou grafei
oti [`main' must return `int'].

> a.cc: In function `int main(...)':
> a.cc:6: declaration of C function `int main(...)' conflicts with
> a.cc:2: previous declaration `int main(char*)' here

Sthn grammh 2 uparxei to opening { gia mia function pou  legetai
`main' kai einai tupou `int main(char*)' alla esu sth grammh 6
anoigeis to body mias deuterhs `main' me tupo `int main(...)' pou exei
diaforetiko tupo apo thn arxikh.  (Oi treis teleies den einai kati
sugkekrimeno, einai apla placeholder gia to prototype pou esu edoses
sthn grammh 6, ki oxi o plhrhs tupos).

> Gia prospathise na moy eksigiseis to parapano. 

Prospathisa :)
Den jero poso kala to katafera omws.

> Den tha eprepe na ginei compile?

Oxi.  Exei orismenh duo fores mia function me to idio onoma.  Akoma
kai akribos idies na einai, copy-paste h mia ths allhs, einai duo
fores to idio function, kai TOULAXISTON ena warning prepei na sou
bgalei o compiler.

> Kai ektos aytoy, ante bgale akri apo to error message, poy leei oti
> yparxoyn 2 "int main()"

Ma uparxoun.  Ti se paraksenepse?

-giorgos



More information about the Linux-greek-users mailing list