[Bug target/15037] -ffreestanding not taken into account when compiling main()

wilson at specifixinc dot com gcc-bugzilla@gcc.gnu.org
Wed Apr 21 19:17:00 GMT 2004


------- Additional Comments From wilson at specifixinc dot com  2004-04-21 19:09 -------
Subject: Re:  -ffreestanding not taken into account when
 compiling main()

xtrochu at yahoo dot com wrote:
> ------- Additional Comments From xtrochu at yahoo dot com  2004-04-21 11:54 -------
> Looking up the documentation for "-ffreestanding", I see no reason why the
> compiler should make _any_ assumption about "main()" being the entry point of a
> program, and thus would include hidden calls to a __main() or _alloca() function.

This is more a target (cygwin) problem than a -ffreestanding problem.

Some targets provide a mechanism for running C++ static constructors and 
destructors, and some don't.  The ones that don't require the __main 
function.  This isn't something we can fix, as we don't control MS 
Windows.  On a target like cygwin, it is not possible to get a true 
freestanding environment and have a fully working compiler.

The -ffreestanding option is primarily useful for embedded target ports 
that assume no OS.  It also works correctly for most ELF targets. 
However, in general, you can't turn a hosted environment into a 
freestanding environment simply by using a compiler option.

 > The actual behavior is that you simply can't use the word "main" as a 
 > function name in freestanding environment,

This is false.  If a target fully supports -ffreestanding, then you can 
safely use main as a function name.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15037



More information about the Gcc-bugs mailing list