This is the mail archive of the
mailing list for the GCC project.
When running a C cross compiler where one does not want a call
to "__main()" to be emitted, how can one turn it off?
Thanks in advance,
----- Original Message -----
From: "Fergus Henderson" <firstname.lastname@example.org.OZ.AU>
To: "Robert Spanton" <email@example.com>
Sent: Thursday, August 29, 2002 11:40 AM
Subject: Re: __main
> On 29-Aug-2002, Robert Spanton <firstname.lastname@example.org> wrote:
> > Why is it that when i compile the following code (using the -S switch)
> > windows, GCC outputs an assembly file containing the symbol "__main"
> > underscores) AND the symbol "_main" (one underscore) - whereas when i
> > compile it under unix or bsd, it only contains the symbol "_main" (one
> > underscore). Why do the unix and bsd versions not output the symbol
> > "__main"?
> On some systems, gcc inserts a call to __main() at the start of the
> code that it generates for main(). __main() is called to execute
> initialization code, in particular constructors for C++ objects with
> global or namespace scope.
> On systems which use the ELF object file format, there are special
> sections in the object file for registering initialization code, and
> gcc will use these. The program loader (and/or the C runtime start-up
> code) will then ensure that the initialization code gets run, perhaps
> even before main() is entered, so there's no need for gcc to call
> Fergus Henderson <email@example.com> | "I have always known that the
> The University of Melbourne | of excellence is a lethal habit"
> WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.