How to hide NVCC's “function was declared but never referenced” warnings?
问题 When compiling CUDA programs which use Google Test, nvcc will emit false-positive warnings: function <name> was declared but never referenced An MCVE: // test.cu #include <gtest/gtest.h> namespace { __global__ void a_kernel() { printf("Works"); } TEST(ExampleTest, ExampleTestCase) { a_kernel<<<1, 1>>>(); } } Compiling it gives: $ nvcc test.cu -lgtest -lgtest_main test.cu(9): warning: function "<unnamed>::ExampleTest_ExampleTestCase_Test::ExampleTest_ExampleTestCase_Test()" was declared but