NOT Dexter's Lab

VC++ 2008 and CUDA (NVIDIA)

by on Nov.23, 2008, under Development

Let me guess: you just wrote your new, shining CUDA application to unleash all the horsepower of your GPU and you are getting some compilation errors in Visual Studio. Some really weird errors. Something like:

1>CUDA_myfile.cu_generated.c
1>C:\Programmi\Microsoft Visual Studio 9.0\VC\INCLUDE\vadefs.h(52) : error C2059: syntax error : ‘string’
1>C:\Programmi\Microsoft Visual Studio 9.0\VC\INCLUDE\vadefs.h(61) : error C2059: syntax error : ‘string’
1>c:\cuda\include\vector_types.h(426) : error C2059: syntax error : ‘type’
1>c:\cuda\include\vector_types.h(427) : error C2059: syntax error : ‘type’
1>c:\cuda\include\vector_types.h(428) : error C2054: expected ‘(‘ to follow ‘operator’
1>c:\cuda\include\vector_types.h(428) : error C2059: syntax error : ‘type’
1>c:\cuda\include\vector_types.h(430) : error C2059: syntax error : ‘}’
1>C:\CUDA\bin/../include\cuda_runtime_api.h(79) : error C2059: syntax error : ‘string’
1>C:\Programmi\Microsoft Visual Studio 9.0\VC\INCLUDE\crtdefs.h(485) : error C2059: syntax error : ‘string’

Right? This is your lucky day. After some struggling, I figured out the solution to this weird issue! Simply right click on the file in the “Solution Explorer” then selectd “Properties”. Now choose “Compile as C++ Code (/TP)” in “Configuration Properties->C/C++->Advanced->Compile As” and apply the changes. Compile your project and.. it should work.

:,

  • http://Website Brad

    You are a champion! I was pulling my hair out with these errors. Dont know how you figured it out but thank you so much!

  • http://www.a2p.it Alessio Placitelli

    You’re welcome ;-) I’m glad my experience helped.. !

  • Wego_4_ever

    hi I tried your solution but it still gives me the same error . could you help?

  • http://www.a2p.it/ Alessio Placitelli

    Are you sure the problem is the very same? Once you make the generated file compile as C++ instead of C, are the errors exactly the same and on the same file as before?

    Another simple test would be to change the file extension to cpp instead of c and check again :D Let me know!

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!