This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: trunk merged into MELT branch after C++ conversion


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]