I am trying to build a library, multiple functions will need one same data array. This data array has a large number of data, so I put the data in one single file. Say I name it as “a.h”
#ifndef A_H_
#define A_H_
int a[30000] = {1, 0, -1, 0, -1, 0, ......}
#endif
In fun1.cu, I use: #include “a.h” ; In fun2.cu, I also use: #include “a.h”
Compiler gives me error of multiple definition of “a”
How can I correct it?
I understand that if both fun1.cu and fun2.cu need to utilize the same function, common(). I can put the function prototype in a header file, common.h, and can put function definition in a source file, common.cpp. Then both fun1.cu and fun2.cu can use #include “common.h” to include the same function, in this way there is no multiple definition error for using this common().
But how about one common data array?
Thanks for any advice