Problems Including <d3dx9.h> in .cu file

Spent hours on this and I think I need help, so I’ve condensed the problem to its shortest size possible for this post. Basically, I have three files, as shown below:

---------- main.cpp

#include <d3dx9.h>

#include "dx.h"

int main(int argc, char *argv[])


	return 0;



#include <d3dx9.h>

#include "dx.h"

---------- dx.h

#pragma once

class TestDX {


	int i;

	MSG msg;


If I exclude the .cu file from the project, it compiles perfectly. However, with the file in, it won’t compile since for some reason, CUDA won’t allow me to #include <d3dx9.h>. I get the cryptic error: 1>z:\zmain_dan\code_libs\directx_june2010\include\d3dx9math.h(416) : error C2059: syntax error : ‘’

… in the “d3dx9math.h” file on this line:


So can we find some way of getting CUDA to be friends with d3dx9.h/d3dx9math.h (perhaps by upgrading to the latest CUDA?)…?

Same problem with Cuda 4.0 & VC2008 - did you ever solve it?

… splitting the typedef in two is the workaround:



It seems nvcc doesn’t like/understand the comma used to declare the pointer version in the same typedef.

It’s not something I’ve ever used myself either, I didn’t know you could. Would be nice if this could be fixed (note I’m still using the Feb 2010 version of DX, maybe it’s changed in the current one?).