trunk merged into MELT branch after C++ conversion

Marc Glisse marc.glisse@inria.fr
Wed Aug 29 13:09:00 GMT 2012


On Wed, 29 Aug 2012, Basile Starynkevitch wrote:

> I discovered a strange property of C++ regarding symbols. If you just code
>
>   // file foo1.cc
>   extern "C" {
>     const int twosymb=2;
>   };
>
> the resulting foo1.o does not define a twosymb symbol (I expected that it does).
> You have to code
>
>   // file foo2.cc
>   extern "C" {
>     extern const int twosymb;
>     const int twosymb=2;
>   };
>
> to get a symbol "twosymb" in foo2.o

Yes, that's one of the usual traps about C vs C++. Note that you can write 
everything on the same line...

extern "C" const int twosymb = 2;

-- 
Marc Glisse



More information about the Gcc mailing list