I am trying to use the __thread specifier to create a thread local variable. This works OK in the following code:
#include <stdio.h>
#include <pthread.h>
static __thread int val;
int main()
{
val = 10;
}
But if I try to use the __thread specifier in a class as follows:
#include <stdio.h>
#include <pthread.h>
class A
{
public:
A();
static __thread int val;
};
A::A()
{
val = 10;
}
int main()
{
A a;
}
I get the compiler error: undefined reference to 'A::val'