如何禁用特定的nvcc编译器警告 [英] How to disable a specific nvcc compiler warnings
问题描述
我想使用 nvcc
禁用特定的编译器警告,特别是
I want to disable a specific compiler warning with nvcc
, specifically
警告:不允许使用NULL引用
warning: NULL reference is not allowed
我正在处理的代码使用 NULL
引用是SFINAE的一部分,因此不可避免。
The code I am working on uses NULL
references are part of SFINAE, so they can't be avoided.
一个理想的解决方案是 #pragma
仅在我们要禁用警告的源文件中,但如果存在一个编译器标志,也可以将其仅关闭有问题的警告。
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.
推荐答案
实际上可以在具有NVCC的设备上禁用特定警告。
It is actually possible to disable specific warnings on the device with NVCC. It took me ages to figure out how to do it.
您需要将 -Xcudafe
标志与此页面上列出的令牌。例如,要禁用控制表达式为常数警告,请将以下内容传递给NVCC:
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.
这篇关于如何禁用特定的nvcc编译器警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!