How to disable a specific nvcc compiler warnings

bcumming picture bcumming · Feb 12, 2013 · Viewed 9.9k times · Source

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.

Answer

user2333829 picture user2333829 · Jun 13, 2013

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.