question about variable definition

In one foo.cu:

#include **
#define **

static int l, k;

global void kernel(){
double *x;
x[l]=…

}

Error: l is not defined. What is wrong? Thanks.

static variables are not supported in device code.

I modified ¨static int l, k;“to ¨int l, k;”. There is still error: l is undefined.

With “static” he meant variables with global lifetime, which means global variables and function-level static variables (unfortunately “static” has many different meanings in C).

Note that texture references are an exception to that rule, actually they have to be global (I suspect they are implemented as just a kind of preprocessor hack).

Thank you for your reply. I have solved this problem.
In fact, variable l and k are defined in CPU memory, which are not accessed by GPU global memory.
We must use cudaMemcpyHostToDevice to allocate the space and copy it to device memory.
That is OK!