CUDA程序如何解决 warning C4819?


用VS2010编译CUDA示例时,有很多C4819警告:
warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
按网上说的一个个的重新保存不实际,而CUDA项目配置属性中又没有禁用特定警告这一项
请问如何解决?

visualstudio cuda

奥巴马·本拉登 11 years, 6 months ago

这个警告,跟代码本身无关,而是某一行里面,存在一个或者多个Unicode字符,查找起来非常困难。一个简单的办法:打开出现warning的文件,Ctrl+A全选,然后在文件菜单:file->Advanced save options,在弹出的选项中选择新的编码方式为:UNICODE- codepage 1200 ,点确定后编译。

或者,在代码中加上:#pragma warning(disable:C4819),直接忽略这个警告。

最简单的办法:
在cuda工程设置中,cuda runtime API的Host选项卡中的Extra C++ Option中填入/WD4819就直接搞定了,根本不用改代码或者是从新保存文件!!!!!!!!!!!!!!!

Chero answered 11 years, 6 months ago

Your Answer