compilation of device_launch_parameters.h and curand_kernel.h together produces errors related to C+

In my cuda-c++ project, I am using cuRAND library for generating random numbers and I have included below files in my header file:

// included files in header file
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <curand_kernel.h>  // cuRAND lib
#include "device_launch_parameters.h"

I am able to compile my project on Windows 7 and Windows 8 with no errors. But when I tried to compile it on linux with g++ (GCC) 4.4.7 (Red Hat 4.4.7-16), I am getting below error:

/usr/local/cuda-7.5/bin/../targets/x86_64-linux/include/curand_mtgp32_kernel.h:122: error: previous declaration of ‘const uint3 threadIdx’ with ‘C++’ linkage
/usr/local/cuda-7.5/bin/../targets/x86_64-linux/include/device_launch_parameters.h:71: error: conflicts with new declaration with ‘C’ linkage
/usr/local/cuda-7.5/bin/../targets/x86_64-linux/include/curand_mtgp32_kernel.h:121: error: previous declaration of ‘const dim3 blockDim’ with ‘C++’ linkage
/usr/local/cuda-7.5/bin/../targets/x86_64-linux/include/device_launch_parameters.h:73: error: conflicts with new declaration with ‘C’ linkage
make: *** [host] Error 1

I can see “threadIdx” and “blockDim” declared as “extern” in “curand_mtgp32_kernel.h” and actual definitions in “device_launch_parameters.h”.

I am not sure what this error means and how should I resolve it?

The correct answer was already given in one of the comments on your cross-posting on stackoverflow.

I’m not sure where your stackoverflow question is located. Can you please tell me how you solved this issue? I am currently having the same issue.