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]

 



Am 03/24/2014 08:04 AM, schrieb Kilian, Jens:
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).

But that's strange. With this little example:

----- test.cpp ----------

#include <iostream>

class A {
public:
    int a;
    A() { a = 5; }
    void showA() { std::cout << a << std::endl; }
};

A a;

int main(int argc, char * argv[]) {
    a.showA();
    return 0;
}

----- test.cpp ----------

and doing

g++ -static -O0 -o test test.cpp
nm test | grep main

no __main pops up.

Could be inlined though?

But there is a
__libc_start_main
symbol, maybe __main got renamed?

Yours sincerely,

Eric Wolf




[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