It appears that OpenMP implementation in Visual Studio 2010 has a serious bug that does not allow to have external variables as threadprivate. The the following code would not compile:
file.c
#include <omp.h>
/* Declaration of external variable. */
extern int My_Var;
#pragma omp threadprivate (My_Var)
void MyFunc(void) { My_Var = 1;}
The error message is:
error C3053:
'My_Var' : 'threadprivate' is only valid for global or static data tems.
Clearly the compiler is confused about linkage attribute of the variable.
It is most common to refer global variables in multiple files. So this problem makes threadprivate
directive unusable in any realistic program.
I wonder if there are tricks to handle this bug. Unfortunately in my case this problem prevents me to use OMP completely.
Thank you,
Alex
/openmp /LD
?