‘cudaDeviceProp’ undeclared

I am trying to do something like

cudaDeviceProp deviceProp;

cudaGetDeviceProperties(&deviceProp, device);

but when i compile using

nvcc cuda_tools.c

i get the error

cuda_tools.c:32: error: ‘cudaDeviceProp’ undeclared (first use in this function)

cuda_tools.c:32: error: (Each undeclared identifier is reported only once

cuda_tools.c:32: error: for each function it appears in.)

cuda_tools.c:32: error: expected ‘;’ before ‘deviceProp’

cuda_tools.c:33: error: ‘deviceProp’ undeclared (first use in this function)

I’ve tried including cuda.h, cuda_runtime.h, cuda_runtime_api.h and driver_types.h but this didn’t seem to work.

I’m using Cuda compilation tools, release 3.1, V0.2.1221 on Ubuntu 10.04 with gcc 4.3.4.

What am I doing wrong here?

I think you will find those CUDA runtime declarations are intended for C++, not C. If you rename the file to have a .cc or .cu extension, nvcc will use the C++ compiler on the code and I suspect it will work correctly.