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

Ian Lance Taylor iant@google.com
Thu Mar 20 18:23:00 GMT 2014


On Thu, Mar 20, 2014 at 9:38 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> Global ctors/dtors are a separate issue, I'm not sure how they're
> handled if main() isn't written in C++.

It doesn't matter.  As a GCC extension, you can write a global
constructor in C using __attribute__ ((constructor)), and the result
is equivalent to a C++ global constructor.  It follows that if global
constructors work at all, they will work whether main is written in C
or C++.

Ian



More information about the Gcc-help mailing list