1

There is some C++ code in a CUDA file that uses this pragma:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
    void foobar()
    {
        // some code
    }
#pragma GCC diagnostic pop

When this CUDA file is compiled using CUDA 5.5 nvcc compiler, the host compiler stage is fine, but the device compiler stage produces this warning:

foobar.cu(420): warning: unrecognized GCC pragma

It looks like the CUDA compiler understands that this is a GCC pragma. I have no idea why it is trying to understand all GCC pragmas. Is there any method to fix this warning or make this warning go away?

Update: Please note that passing the -Xcudafe "--diag_suppress=unrecognized_pragma" option to the nvcc compiler does not seem to have any effect.

Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
  • possible duplicate of [How to disable compiler warnings with nvcc](http://stackoverflow.com/questions/14831051/how-to-disable-compiler-warnings-with-nvcc) – rubenvb Apr 01 '14 at 07:52

2 Answers2

2

Try this one:

-Xcudafe "--diag_suppress=unrecognized_gcc_pragma"
6EQUJ5
  • 3,142
  • 1
  • 21
  • 29
  • Thanks! That worked. May I know where I should look for such flags? In case, I need to ignore a different warning in the future :) – Ashwin Nanjappa Apr 09 '14 at 02:52
  • Anyone using cmake can add: `set(CMAKE_CUDA_FLAGS_RELEASE "-Xcudafe \"--diag_suppress=unrecognized_gcc_pragma\"")` to their relevant `CMakeLists.txt` file – schuess Jul 12 '22 at 18:03
1

As shown in the duplicate question, you need to pass the following flag to nvcc:

-Xcudafe "--diag_suppress=unrecognized_pragma"
Community
  • 1
  • 1
rubenvb
  • 74,642
  • 33
  • 187
  • 332