Re: C++ templates and visibility("hidden")

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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;
}


no you don't. I don't know what's wrong with your example but the following works:

test.h:
template<typename T>
struct API A{
  void f();
};

test.cpp: -fvisibility=hidden -shared
#define API __attribute__((visibility("default")))
#include "test.h"

template<typename T>
void A<T>::f(){}

template class A<int>;


test2.cpp: -ltest #define API #include "test.h"

int main(){
  A<int> a;
  a.f();
}



--
Stefan Strasser

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux