On Saturday 09 April 2005 6:04 pm, Stefan Strasser wrote: > Christian Parpart schrieb: > > Hi all, > > > > I'm not sure that I ran into a bug, but I'm quite sure about that - > > because the other way around just looks ugly. > > > > When using CXXFLAGS="-fvisibility=hidden" and declaring the following in > > a file for a shared library: > > > > #define MY_API __attribute__((visibility("default"))) > > > > template<class T> > > MY_API class U { > > public: > > void f(T v); > > }; > > listen to your compiler: > c++template-visibility.h:19: warning: attribute ignored in declaration > of 'class TFoo<T>' > c++template-visibility.h:19: warning: attribute for 'class TFoo<T>' must > follow the 'class' keyword > > and note that you can only export instantiations of templates. Okay, I did s,MY_API class,class MY_API. Now, when using colorgcc, I even saw the warning you hinted me :) However, when playing a bit around, I see, that I've to explicitely do: template<class T> void FOO_API TFoo<T>::bar(const T& var) { std::cout << "TFoo::bar(" << var << ")" << std::endl; } that is, adding the FOO_API right into the .cpp file's function implementation to get this working. Is this really supposed to be required? Well, I specified FOO_API in the .h file between class and TFoo to achieve this. So, I wonder why I've to add FOO_API in the function implementations header, too. Regards, Christian Parpart. -- Netiquette: http://www.ietf.org/rfc/rfc1855.txt 17:10:29 up 17 days, 6:16, 1 user, load average: 0.58, 0.96, 0.79
Attachment:
pgpN0nRt3lyHU.pgp
Description: PGP signature