Skip to content

Commit 233b6f3

Browse files
harrismclaude
andcommitted
NanoVDB: fix remaining Windows warnings-as-errors fallout
Clearing the dll-interface diagnostics unblocked the Windows projects to compile further, exposing two more pre-existing warning classes that NANOVDB_CUDA_WERROR now promotes to errors: Guard the _USE_MATH_DEFINES definition in the four examples that define it. The Windows build also passes -D_USE_MATH_DEFINES on the command line (as 1), so the bare #define (empty) triggered MSVC C4005 macro-redefinition warnings, which the flag turns into C2220 errors. Suppress EDG #177 for the CUDA gtest targets on Windows. gtest's TEST macro declares each test's static test_info_ member with an unused-attribute on GCC/Clang but not under MSVC, so for tests defined inside an anonymous namespace (TestBuffer.cu, TestMemoryResource.cu, TestUtilCuda.cu) the front end proves it unreferenced and reports #177 -- 76 errors, all from the macro machinery, none actionable in our code. TestNanoVDB.cu is unaffected because its tests are declared at namespace scope. The suppression is per-target and Windows-only, so #177 stays enforced for all library headers, tools and examples on every platform, and for everything on Linux. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Mark Harris <mharris@nvidia.com>
1 parent 9d94edf commit 233b6f3

5 files changed

Lines changed: 20 additions & 0 deletions

File tree

nanovdb/nanovdb/examples/ex_collide_level_set/nanovdb.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright Contributors to the OpenVDB Project
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#ifndef _USE_MATH_DEFINES
45
#define _USE_MATH_DEFINES
6+
#endif
57
#include <cmath>
68
#include <chrono>
79

nanovdb/nanovdb/examples/ex_raytrace_fog_volume/nanovdb.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright Contributors to the OpenVDB Project
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#ifndef _USE_MATH_DEFINES
45
#define _USE_MATH_DEFINES
6+
#endif
57
#include <cmath>
68
#include <chrono>
79

nanovdb/nanovdb/examples/ex_raytrace_iso_surface/nanovdb.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright Contributors to the OpenVDB Project
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#ifndef _USE_MATH_DEFINES
45
#define _USE_MATH_DEFINES
6+
#endif
57
#include <cmath>
68
#include <chrono>
79

nanovdb/nanovdb/examples/ex_raytrace_level_set/nanovdb.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright Contributors to the OpenVDB Project
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#ifndef _USE_MATH_DEFINES
45
#define _USE_MATH_DEFINES
6+
#endif
57
#include <cmath>
68
#include <chrono>
79

nanovdb/nanovdb/unittest/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ if(NANOVDB_USE_CUDA)
7979
target_link_libraries(nanovdb_test_cuda_buffer PRIVATE nanovdb GTest::GTest GTest::Main)
8080
set_target_properties(nanovdb_test_cuda_buffer PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
8181
add_test(nanovdb_cuda_buffer_unit_test nanovdb_test_cuda_buffer)
82+
83+
if(WIN32)
84+
# gtest's TEST macro declares each test's static test_info_ member with an
85+
# unused-attribute on GCC/Clang but not under MSVC, so for tests defined
86+
# inside an anonymous namespace the CUDA front end can prove it
87+
# unreferenced and reports #177, which NANOVDB_CUDA_WERROR promotes to an
88+
# error. Suppress #177 for the CUDA test sources that use that style.
89+
foreach(_cuda_gtest nanovdb_test_cuda_buffer nanovdb_test_cuda_memory_resource
90+
nanovdb_test_cuda_util nanovdb_test_cuda_util_sync)
91+
target_compile_options(${_cuda_gtest} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:--diag-suppress=177>")
92+
endforeach()
93+
endif()
8294
endif()
8395

8496
# -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)