NOT Dexter's Lab

VC++ 2008 e CUDA (NVIDIA)

by on Nov.23, 2008, under Development

Lasciatemi indovinare: avete appena scritto la vostra nuova, fiammante, applicazione CUDA per scatenare tutta la potenza della vostra GPU e vi ritrovate alcuni strani errori in Visual Studio durante la compilazione. Errori tipo:

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’

Giusto? Oggi è il vostro giorno fortunato. Dopo un pò di delirio, ho trovato la soluzione a questo insolito problema! Fate semplicemente click di destro sul file nel “Solution Explorer” e scegliete “Proprietà”. Ora impostate “Compile as C++ Code (/TP)” in “Configuration Properties->C/C++->Advanced->Compile As”e salvate le modifiche. Provate a compilare e.. dovrebbe andare!

:,

  • 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!