This is a C/C++ problem and have nothing to do with CUDA.
Generally people don't include source files like .cu .cpp .c. Only header files like .h should be included.
If you have a global variable int x
need to be referenced in many source files. You could define it in one souce file as
// main.cu
int x;
...
declare it in a header file as
// main.h
extern int x;
...
and include this header file in all the source files you will reference that variable as
// second.cu
#include "main.h"
void foo() {
int local=x;
}
...
and
// third.cu
#include "main.h"
void bar() {
int private=x;
}
...