CUDA, Intellisense, and Visual Studio (a simple solution) Simple, maybe naive, but hey... it works :

Without even some manual knob-turning the C/C++ syntax in the .cu files is not even highlighted, but what about functions and variables names completion? What about Intellisense (VS)?

Let’s start by having a project that already works as far as compiling the .cu files with NVCC (using the custom build rule for the .cu files [if needed I can post the one used in nVIDIA’s sample projects]).

Well, the basic idea is to write your .cu code (for the main file and for the kernels) in nice .C files (C++ syntax) and set those “would be .cu files” to compile using a custom build rule (check that this rules comes before the CUDA/NVCC one in the build tools order for your project).

The custom build rule for these “dummy” .C files, thanks to VS’s Macros (env. vars), is not tough to write…

Command Line:

rm (InputName).cu cp (InputFileName) $(InputName).cu

Description (nice console output):

(InputFileName) --> (InputName).cu



The idea is to basically have a .C file for each .cu file and set those .C files compilation step appropriately to just “transform” them into .cu files for you giving you back Intellisense (for your code and for CUDA SDK’s functions and macros too) at a very minor cost.

If I have explained myself poorly, please do ask any question you might have and I’ll try to answer it.


say you have your main .cu file named (when you split in one main .cu file and several kernel files then the kernel files are usually excluded from the build process, included by the main .cu file itself, and referenced in the custom build process of the main .cu file)… and this file references a

If you just created it, then you might have to set the Custom Build process for it (it cannot just use NVCC directly as Visual Studio attempts it to do automatically)… so you right click on the file and click on Properties…

You set it to use a Custom Build Tool (General), you click on Apply, and then you configure the custom build process…

Command Line:

(CUDA_BIN_PATH)\nvcc.exe" -ccbin "(VCInstallDir)bin” -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MTd -I"(CUDA_INC_PATH)" -I./ -I../../common/inc -o (ConfigurationName)\MatTest.obj



Additional Dependencies:

Good idea.

But it begs the question… why can’t you just name your CUDA files .c? (I tried this, and nvcc threw a hissy fit.)

Also, for intellisense to work, you need to manually include all the headers that nvcc includes automatically. Do you happen to know what those are?

As far as I am using it now, I make a new project inside CUDA’s projects directory, and I set up in the VS Project’s C/C++ options

the additional includes to: “$(CUDA_INC_PATH)”;./;…/…/common/inc

Intellisense looks over there, in your code, and in the files you include in the code itself.