printf causes "unknown error" on kernel launch

Hi!

Here’s the code that doesn’t work
global void assign_centroids(Datapoint* data, long n, int k, bool* global_reassigned)
{
long id;
id = blockDim.x * blockIdx.x + threadIdx.x;
if(id >= n)
return;
printf(“data[id] b[%d], t[%d], id[%ld]\n”, blockIdx.x, threadIdx.x, id);
}

Here’s the code that works
global void assign_centroids(Datapoint* data, long n, int k, bool* global_reassigned)
{
long id;
id = blockDim.x * blockIdx.x + threadIdx.x;
if(id >= n)
return;
//printf(“data[id] b[%d], t[%d], id[%ld]\n”, blockIdx.x, threadIdx.x, id);
}

Is it because I am trying to print a long? If so, is there any way to print longs?

Thanks!

(1) Can you provide a complete, self-contained, compilable example code?
(2) Can you show the exact nvcc invocation used to compile the code?
(3) What version of CUDA is used?
(4) What OS platform and what GPU is used?
(5) Does your code check the status of every CUDA API call and every kernel launch?