This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: __main?


On Jan 26, 2001, Axel Kittenberger <Anshil@gmx.net> wrote:

> Unfortunally one of my routines is called "main", and somehow gcc seems to
> handle that one specially :), however in my case this just a function like
> every one else.

How is GCC supposed to figure it out?  main() *is* a special function
in C.  You aren't even allowed to take its address or to call it.
Don't name a regular function main().

> To be exact, after compiling that file containing the main function
> it stops at linking stage with an unresolved link to "__main".
> [...]  Did gcc create that? or what is it?

Yep.  On certain platforms, GCC arranges for main() to call __main(),
that runs static initializers.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]