Some special characters in cuda files cause annoying warning messages at compilation


I am working on Windows 7 64 bit, with system default encoding set to Chinese. When I compile my project, I got the hundreds of warnings likes the following:

c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\math_function
s.h(7195): warning C4819: The file contains a character that cannot be represen
ted in the current code page (936). Save the file in Unicode format to prevent
data loss [D:\cygwin64\home\Xi\projects\hello_cuda\build\hello_cuda.vcxproj]

For this case, the line is:

  • <m:mo>±</m:mo>

I believe the “±” character is a special UTF-8 character

Any idea how to remove these warnings?


These warnings are produced by the host compiler, that is, MSVC. You should be able to disable them by adding this flag to the nvcc command line:

-Xcompiler “/wd 4819”

awesome, adding

set(CUDA_NVCC_FLAGS "-Xcompiler “/wd 4819"”)

to my CMakeLists.txt file solved my problem.

Thanks a lot!