C and CUDA

Hi,

I have a strange error. I have a C code that compiles fine under MS visual express. It has 4 files, main.c vec.h solver.h and solver.c. When I added a cuda file, cppint.cu and included the header solver.h I get the following error:

1>Compiling...

1>cppint.cu

1>c:\program files\nvidia corporation\nvidia cuda sdk\projects\minisat-c_v1.14.1 - graphic\solver.h(35): error: invalid combination of type specifiers

1>c:\program files\nvidia corporation\nvidia cuda sdk\projects\minisat-c_v1.14.1 - graphic\solver.h(36): error: expected an identifier

1>c:\program files\nvidia corporation\nvidia cuda sdk\projects\minisat-c_v1.14.1 - graphic\solver.h(37): error: expected an identifier

regardless of what I have in the .cu file. I am at the point where I only have the header file solver.h in the .cu file (nothing else its pretty much and empty file). When I take that out, the errors disappear and everything compiles fine even with the .cu file. I have tried using extern “C” {“solver.h”} but that didnt make a difference. I have had code in the .cu without the solver.h header file and it runs fine. I am sure the errors are not related to the solver.h since without adding it to the .cu file it compiles just fine. Just in case here is the code that generates the error in the solver.h:

typedef int  bool;

static const bool  true      = 1;

static const bool  false     = 0;

Any help is very much appreciated…

bool may be a reserved keyword. have you tried replacing it with something else, say mybool ?

Thank you!!! I don’t know how I missed that. I guess it throw me off that the code compiled at first with no problems. Plus staying up all night working on this thing. I went and changed all the bool, true, and false to different names that are not reserved as per your advice and now it works perfectly.

Actually you did not miss anything, it is just nvcc being too stupid to know the difference between C and C++, so in the end neither C nor C++ really works.

My suggestion: make sure you know a bit of both C and C++ and only use code that works in both, for me this was the most reliable way to use nvcc.