Skip to content

Commit 6db1e04

Browse files
committed
Replacing non-portable warning-suppression pragma with a dummy implementation.
1 parent e72019f commit 6db1e04

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/test_make_caster_adl.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ struct unnamed_ns_type_mock {};
2323
struct unnamed_ns_mock_caster {
2424
static int num() { return 303; }
2525
};
26-
#if defined(__GNUC__)
27-
# pragma GCC diagnostic push
28-
# pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
29-
#endif
3026
unnamed_ns_mock_caster pybind11_select_caster(unnamed_ns_type_mock *);
31-
#if defined(__GNUC__)
32-
# pragma GCC diagnostic pop
27+
#if !defined(_MSC_VER)
28+
// Dummy implementation, purely to avoid compiler warnings (unused function).
29+
// Easier than managing compiler-specific pragmas for warning suppression.
30+
// MSVC happens to not generate any warnings. Leveraging that to prove that
31+
// this test actually works without an implementation.
32+
unnamed_ns_mock_caster pybind11_select_caster(unnamed_ns_type_mock *) {
33+
return unnamed_ns_mock_caster{};
34+
}
3335
#endif
3436
} // namespace
3537

@@ -79,4 +81,9 @@ TEST_SUBMODULE(make_caster_adl, m) {
7981
return obj;
8082
});
8183
m.def("mrc_arg", [](mrc_ns::type_mrc const &obj) { return obj.value + 2000; });
84+
85+
#if !defined(_MSC_VER)
86+
// Dummy call, purely to avoid compiler warnings (unused function).
87+
(void) pybind11_select_caster(static_cast<unnamed_ns_type_mock *>(nullptr));
88+
#endif
8289
}

0 commit comments

Comments
 (0)