如何使用nvcc禁用编译器警告 [英] How to disable compiler warnings with nvcc

查看:636
本文介绍了如何使用nvcc禁用编译器警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 nvcc 禁用特定的编译器警告,特别是


警告:不允许NULL引用


我正在使用的代码使用 NULL 引用是 SFINAE 的一部分,因此无法避免。



理想的解决方案是 #pragma 在我们想要禁用警告的源文件中,但是编译器标志也可以,如果存在只关闭有问题的警告。 p>

编辑:我一直与NVIDIA的某人联系,他们告诉我,目前没有方法禁用来自设备的警告编译器。对于来自主机编译器的警告,您可以使用类似以下标志:


-Xcompiler -Wnonull


我要结束这个问题。

解决方案

实际上可以使用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.

这篇关于如何使用nvcc禁用编译器警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆