Help with C integration not C++

Hi Everyone

I am trying to integrate .C files (not C++) with CUDA, and I have seen the SDK example “cppintegration”
which use the extern “C”, but it doesn’t work for the .C files and shows

error C2059: syntax error : ‘string’

I learned that extern “C” only works for C++, but what if I want to complie .c files instead of .cpp?
Could anybody please help me out?

Thank you very much!

If you’re compiling .c files (and the compiler properly interprets this, switching itself to pure C mode) you don’t need extern “C”.

extern “C” is needed specifically when you interact native C with C++.

I actually never encountered a case where I need to use this extern “C”.
Could anyone give a short example?
All my CUDA programs compile without it.

I think it is possible to omit it as of CUDA 2.2 or 2.3 if I remember correctly.

eyal

If you are a relatively new CUDA user, you probably would never have run into the need. Somewhere around version CUDA 2.0 (I think), nvcc started generating C++ mangled names for functions by default thus removing the need to declare them extern “C” in the header file for linking with c++ code compiled by the host compiler.