且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用nvcc禁用编译器警告

更新时间:2022-10-17 13:12:37

实际上可以使用NVCC禁用设备上的特定警告。



您需要使用 -Xcudafe 标志结合在此页面上列出的令牌/ a>。例如,要禁用控制表达式为常量警告,请将以下内容传递给NVCC:

  -Xcudafe--diag_suppress = boolean_controlling_expr_is_constant

有关其他警告,请参阅上述链接


I want to disable a specific compiler warning with nvcc, specifically

warning: NULL reference is not allowed

The code I am working on uses NULL references are part of SFINAE, so they can't be avoided.

An ideal solution would be a #pragma in just the source file where we want to disable the warnings, but a compiler flag would also be fine, if one exists to turn off only the warning in question.

EDIT: I have been in touch with somebody from NVIDIA, and they told me that there currently is no method for disabling warnings that come from the device compiler. For warnings from the host compiler you can use something like the following flags:

-Xcompiler -Wnonull

I'm going to close this question as a result.

It is actually possible to disable specific warnings on the device with NVCC. It took me ages to figure out how to do it.

You need to use the -Xcudafe flag combined with a token listed on this page. For example, to disable the "controlling expression is constant" warning, pass the following to NVCC:

-Xcudafe "--diag_suppress=boolean_controlling_expr_is_constant"

For other warnings, see the above link.