Problems mixing CUDA and C++ code in Eclipse

Hi all,
I’m working on including CUDA elements into an existing C++ application. Ideally, I would like to call CUDA kernels from the dedicated *.cu source files that are #include’d in the C++ files. The problem I’m having is that as soon as a *.cu file is referenced from a *.cpp source, the compiler stops recognizing the CUDA source as such as throws errors along the lines of “expected constructor, destructor or type conversion before ‘void’” when there is a CUDA keyword in the line (like global).

The environment is Eclipse 3.6.1 Helios for 64-bit Linux with the CUDA plugin (ydl.net) installed. The project is defined to use the CUDA toolchain and everything compiles and links perfectly as long as there are no #include references to the *.cu files from within the *.cpp source.

Has anyone seen this type of behavior? Is there an alternative way to integrate CUDA code in a C++ application?
Any suggestions would be appreciated

Thanks

Sasha

Hi all,
I found a working setup. Giving it here in case someone runs into the same problem.
Here’s the combination that worked: a header *.h file has the declaration of the CUDA calling function, the function itself is defined along with the kernel in a *.cu file that includes the header, and the calling C++ source includes the header.
Not sure why the compiler bailed out with the direct reference, but in any event this one works. If someone can explain the different behavior of the compiler, it would be good to know.

Thanks

Sasha