RE: Does g++ really need to compile main, if c++ code is involved?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Florian Weimer [mailto:fw@xxxxxxxxxxxxx]
> * Jens Kilian:
> > I remember only one compiler (HP aCC) which requires compiling main()
> > as C++.  As far as I know GCC never needed this.
> 
> Some systems need collect2 support for initializers:
> 
>   <http://gcc.gnu.org/onlinedocs/gccint/Collect2.html>

I interpret this page to mean that GCC will always call the required __main()
from main(), even if compiling C code.  In this case you wouldn't need to
compile main() using g++ (not gcc).

As other posters have pointed out, this is really platform dependent.
There's a comment in 'libgcc/crtstuff.c' which may be relevant:

  Additionally, if the target system supports a .init section,
  this file allows us to support the linking of C++ code
  with a non-C++ main program.

Best regards,

	Jens.






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux