gcc v3.0.1 vs gcc v2.95.3 -- KDE 2.2.1
Dimitris Moraitis
stud1134 at di.uoa.gr
Fri Nov 30 00:28:01 EET 2001
At 07:21 ìì 29/11/2001 +0200, v13 at priest.com wrote:
>$ cat a.cc
>int main(char *p)
>{
>}
>
>void main(int n)
>{
>}
>
>$ g++ a.cc
>a.cc:6: `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
>
>Gia prospathise na moy eksigiseis to parapano.
>Den tha eprepe na ginei compile? Kai ektos aytoy, ante bgale
>akri apo to error message, poy leei oti yparxoyn 2 "int main()"
>
>An eprepe na einai lathos, tote aplos eprepe na leei oti den
>yparxei h "int main()" (otan exei dilothi mono "void main()" kai
>oxi oti 'prepei na einai etsi'
Katarxhn oson afora to void main() den ksero ti exei ylopoiithei ston
teleftaio gcc.
Afto pou ksero einai afto pou leei to standard:
"5.1.2.2.1 Program startup
1. The function called at program startup is named main. The implementation
declares no prototype for this function. It shall be defined with no
parameters: int main(void) { /* ... */ } or with two parameters (referred
to here as argc and argv, though any names may be used, as they are local
to the function in which they are declared): int main(int argc, char
*argv[]) { /* ... */ } or equivalent,(9) or in some other
implementation-defined manner."
To parapano shmainei oti enas compiler pou den dexetai katholou to void
main() borei na einai ANSI C compliant.
Epishs shmainei oti kai to int main(char *p) pou egrapses einai eksisou
lathos me to void main().
Oson afora to compile tou programmatos sou ennoeitai oti den tha eprepe na
ginei apo thn stigmh pou h C den ypostirizei function overloading. Kai to
programma sou exei conflicting datatypes gia thn synarthsh main.
Tora to error message einai thema tou gcc .... alla molis proseksa oti den
xrhsimopoieis gcc alla g++ opote ta parapano mallon den isyxoun etsi akrivos.
Den thymamai ti akrivos isxyei gia thn c++ oson afora thn main() alla
nomizo isxyei to idio, isos ligo diaforetika diatypomeno sto standard.
Alla exo thn entyposh oti o g++ den einai 100% ANSI/ISO C++ compliant etsi
kai allios.
--
"The last possible deed is that which defines perception itself,
an invisible golden cord that connects us:
illegal dancing in the courthouse corridors.
If I were to kiss you here they'd call it an act of terrorism --
so let's take our pistols to bed & wake up the city
at midnight like drunken bandits celebrating with a fusillade,
the message of the taste of chaos."
More information about the Linux-greek-users
mailing list