• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Template static data members in GCC4 (Undefined symbols link error)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Template static data members in GCC4 (Undefined symbols link error)


  • Subject: Re: Template static data members in GCC4 (Undefined symbols link error)
  • From: Bernard Gilbert <email@hidden>
  • Date: Thu, 16 Jun 2005 21:38:55 -0400

I have a similar problem moving from GCC 3.3 to GCC 4.0 but it creates an undefined symbol link error.

foo.h

template < int bonus >
class foo : public bar
{
public:
    ...
    
private:
    const static RegisterItem<foo> registerItem;
};

foo.cpp

template<> const RegisterItem< foo<1> > foo<1>::registerItem;
template<> const RegisterItem< foo<2> > foo<2>::registerItem;
template<> const RegisterItem< foo<3> > foo<3>::registerItem;
template<> const RegisterItem< foo<4> > foo<4>::registerItem;
template<> const RegisterItem< foo<5> > foo<5>::registerItem;

In other .cpp files I use foo<3>. The code compiles correctly but does not link.

Undefined symbols:
foo<3>::registerItem

I tries moving template<> const RegisterItem< foo<X> > foo<X>::registerItem; into the header, creating some concern over multiple registrations, but this also compiled correctly but did not link with the same error.

Where should template<> const RegisterItem< foo<X> > foo<X>::registerItem; be? As a template specialization normally I would the put it in the header, but as a static and requiring there be only one ( and it worked for GCC 3.3 ) I put it in the .cpp.

How can I resolve the link error?

Thanks,
Bernard Gilbert

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Setting the selection of a document via AppleScript
  • Next by Date: Coding style warnings
  • Previous by thread: Re: MODULE_VERSION and CFBundleVersion synchronization?
  • Next by thread: Coding style warnings
  • Index(es):
    • Date
    • Thread