From aedc4eb76ea92b43d223d55f21b007da28765487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=B6jdh?= Date: Mon, 5 Oct 2026 20:53:25 +0200 Subject: [PATCH] Mark unused binding parameters instead of silencing the warning The pybind11 bindings wrapped their definitions in a GCC diagnostic pragma that ignored -Wunused-parameter. MSVC does not understand the pragma, so the same parameters showed up there as 17 C4100 warnings. Mark the parameters [[maybe_unused]], which every compiler honours, and drop the pragma from all ten headers; four of them had no unused parameter left. --- python/src/bind_Cluster.hpp | 5 ----- python/src/bind_ClusterCollector.hpp | 5 ----- python/src/bind_ClusterFile.hpp | 17 +++++------------ python/src/bind_ClusterFileSink.hpp | 5 ----- python/src/bind_ClusterFinder.hpp | 5 ----- python/src/bind_ClusterFinderMT.hpp | 8 ++------ python/src/bind_ClusterVector.hpp | 7 +------ python/src/file.hpp | 16 ++++++---------- python/src/jungfrau_data_file.hpp | 17 ++++++----------- python/src/raw_sub_file.hpp | 16 ++++++---------- 10 files changed, 26 insertions(+), 75 deletions(-) diff --git a/python/src/bind_Cluster.hpp b/python/src/bind_Cluster.hpp index afa9bfd1..49618bf2 100644 --- a/python/src/bind_Cluster.hpp +++ b/python/src/bind_Cluster.hpp @@ -13,9 +13,6 @@ namespace py = pybind11; using namespace aare; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - template void define_Cluster(py::module &m, const std::string &typestr) { @@ -140,5 +137,3 @@ void reduce_to_2x2(py::module &m) { row-major order. )doc"); } - -#pragma GCC diagnostic pop diff --git a/python/src/bind_ClusterCollector.hpp b/python/src/bind_ClusterCollector.hpp index 01dd03c2..fab91522 100644 --- a/python/src/bind_ClusterCollector.hpp +++ b/python/src/bind_ClusterCollector.hpp @@ -20,9 +20,6 @@ namespace py = pybind11; using namespace aare; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - template void define_ClusterCollector(py::module &m, const std::string &typestr) { @@ -42,5 +39,3 @@ void define_ClusterCollector(py::module &m, const std::string &typestr) { }, py::return_value_policy::take_ownership); } - -#pragma GCC diagnostic pop \ No newline at end of file diff --git a/python/src/bind_ClusterFile.hpp b/python/src/bind_ClusterFile.hpp index c8544e9d..75c5458d 100644 --- a/python/src/bind_ClusterFile.hpp +++ b/python/src/bind_ClusterFile.hpp @@ -13,11 +13,6 @@ #include #include -// Disable warnings for unused parameters, as we ignore some -// in the __exit__ method -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - namespace py = pybind11; using namespace ::aare; @@ -171,14 +166,12 @@ void define_ClusterFile(py::module &m, const std::string &typestr) { .def("__enter__", [](ClusterFile &self) { return &self; }) .def("__exit__", [](ClusterFile &self, - const std::optional &exc_type, - const std::optional &exc_value, - const std::optional &traceback) { - self.close(); - }) + [[maybe_unused]] const std::optional &exc_type, + [[maybe_unused]] const std::optional + &exc_value, + [[maybe_unused]] const std::optional + &traceback) { self.close(); }) .def("__iter__", [](ClusterFile &self) { return &self; }) .def("__next__", [](File &self) { return ChunkIterator(self.chunks()).next(); }); } - -#pragma GCC diagnostic pop diff --git a/python/src/bind_ClusterFileSink.hpp b/python/src/bind_ClusterFileSink.hpp index b366886a..50600fcb 100644 --- a/python/src/bind_ClusterFileSink.hpp +++ b/python/src/bind_ClusterFileSink.hpp @@ -17,9 +17,6 @@ namespace py = pybind11; using namespace aare; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - template void define_ClusterFileSink(py::module &m, const std::string &typestr) { @@ -34,5 +31,3 @@ void define_ClusterFileSink(py::module &m, const std::string &typestr) { const std::filesystem::path &>()) .def("stop", &ClusterFileSink::stop); } - -#pragma GCC diagnostic pop diff --git a/python/src/bind_ClusterFinder.hpp b/python/src/bind_ClusterFinder.hpp index 034b1b88..8872db29 100644 --- a/python/src/bind_ClusterFinder.hpp +++ b/python/src/bind_ClusterFinder.hpp @@ -20,9 +20,6 @@ namespace py = pybind11; using namespace aare; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - template void define_ClusterFinder(py::module &m, const std::string &typestr) { @@ -92,5 +89,3 @@ void define_ClusterFinder(py::module &m, const std::string &typestr) { }, py::arg("frame").noconvert(), py::arg("frame_number") = 0); } - -#pragma GCC diagnostic pop \ No newline at end of file diff --git a/python/src/bind_ClusterFinderMT.hpp b/python/src/bind_ClusterFinderMT.hpp index fdd4b580..7e662841 100644 --- a/python/src/bind_ClusterFinderMT.hpp +++ b/python/src/bind_ClusterFinderMT.hpp @@ -20,9 +20,6 @@ namespace py = pybind11; using namespace aare; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - template void define_ClusterFinderMT(py::module &m, const std::string &typestr) { @@ -55,7 +52,8 @@ void define_ClusterFinderMT(py::module &m, const std::string &typestr) { py::arg("frame").noconvert(), py::arg("frame_number") = 0) .def_property_readonly( "cluster_size", - [](ClusterFinderMT &self) { + []([[maybe_unused]] ClusterFinderMT + &self) { return py::make_tuple(ClusterSizeX, ClusterSizeY); }) .def("clear_pedestal", @@ -93,5 +91,3 @@ void define_ClusterFinderMT(py::module &m, const std::string &typestr) { py::arg("nSigma"), R"(sets the number of sigma for all cluster finders.)"); } - -#pragma GCC diagnostic pop \ No newline at end of file diff --git a/python/src/bind_ClusterVector.hpp b/python/src/bind_ClusterVector.hpp index c7b2932a..13ad5a6d 100644 --- a/python/src/bind_ClusterVector.hpp +++ b/python/src/bind_ClusterVector.hpp @@ -18,9 +18,6 @@ namespace py = pybind11; using namespace aare; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - template void define_ClusterVector(py::module &m, const std::string &typestr) { @@ -123,7 +120,7 @@ void define_ClusterVector(py::module &m, const std::string &typestr) { "padding.") .def_property_readonly( "fmt", - [typestr](ClusterVector &self) { + [typestr]([[maybe_unused]] ClusterVector &self) { return fmt_format(); }, "PEP 3118 format string for one stored cluster.") @@ -228,5 +225,3 @@ void define_3x3_reduction(py::module &m) { )doc", py::arg("clustervector")); } - -#pragma GCC diagnostic pop diff --git a/python/src/file.hpp b/python/src/file.hpp index a493c910..ad303730 100644 --- a/python/src/file.hpp +++ b/python/src/file.hpp @@ -21,11 +21,6 @@ namespace py = pybind11; using namespace ::aare; -// Disable warnings for unused parameters, as we ignore some -// in the __exit__ method -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - void define_file_io_bindings(py::module &m) { PYBIND11_NUMPY_DTYPE(DetectorHeader, frameNumber, expLength, packetNumber, @@ -122,9 +117,12 @@ void define_file_io_bindings(py::module &m) { }) .def("__enter__", [](File &self) { return &self; }) .def("__exit__", - [](File &self, const std::optional &exc_type, - const std::optional &exc_value, - const std::optional &traceback) { + []([[maybe_unused]] File &self, + [[maybe_unused]] const std::optional &exc_type, + [[maybe_unused]] const std::optional + &exc_value, + [[maybe_unused]] const std::optional + &traceback) { // self.close(); }) .def("__iter__", [](File &self) { return &self; }) @@ -160,6 +158,4 @@ void define_file_io_bindings(py::module &m) { .def_property_readonly("start", &ScanParameters::start) .def_property_readonly("stop", &ScanParameters::stop) .def_property_readonly("step", &ScanParameters::step); - -#pragma GCC diagnostic pop } \ No newline at end of file diff --git a/python/src/jungfrau_data_file.hpp b/python/src/jungfrau_data_file.hpp index 44ecd90c..0d9c808b 100644 --- a/python/src/jungfrau_data_file.hpp +++ b/python/src/jungfrau_data_file.hpp @@ -15,11 +15,6 @@ namespace py = pybind11; using namespace ::aare; -// Disable warnings for unused parameters, as we ignore some -// in the __exit__ method -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - auto read_dat_frame(JungfrauDataFile &self) { py::array_t header(1); py::array_t image({self.rows(), self.cols()}); @@ -94,10 +89,12 @@ void define_jungfrau_data_file_io_bindings(py::module &m) { )") .def("__enter__", [](JungfrauDataFile &self) { return &self; }) .def("__exit__", - [](JungfrauDataFile &self, - const std::optional &exc_type, - const std::optional &exc_value, - const std::optional &traceback) { + []([[maybe_unused]] JungfrauDataFile &self, + [[maybe_unused]] const std::optional &exc_type, + [[maybe_unused]] const std::optional + &exc_value, + [[maybe_unused]] const std::optional + &traceback) { // self.close(); }) .def("__iter__", [](JungfrauDataFile &self) { return &self; }) @@ -109,5 +106,3 @@ void define_jungfrau_data_file_io_bindings(py::module &m) { } }); } - -#pragma GCC diagnostic pop \ No newline at end of file diff --git a/python/src/raw_sub_file.hpp b/python/src/raw_sub_file.hpp index 5359c054..5e04674d 100644 --- a/python/src/raw_sub_file.hpp +++ b/python/src/raw_sub_file.hpp @@ -61,11 +61,6 @@ auto read_n_frames_from_RawSubFile(RawSubFile &self, size_t n_frames) { return py::make_tuple(header, image); } -// Disable warnings for unused parameters, as we ignore some -// in the __exit__ method -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - void define_raw_sub_file_io_bindings(py::module &m) { py::class_(m, "RawSubFile") .def(py::init &exc_type, - const std::optional &exc_value, - const std::optional &traceback) {}) + []([[maybe_unused]] RawSubFile &self, + [[maybe_unused]] const std::optional &exc_type, + [[maybe_unused]] const std::optional + &exc_value, + [[maybe_unused]] const std::optional + &traceback) {}) .def("__iter__", [](RawSubFile &self) { return &self; }) .def("__next__", [](RawSubFile &self) { try { @@ -101,5 +99,3 @@ void define_raw_sub_file_io_bindings(py::module &m) { } }); } - -#pragma GCC diagnostic pop \ No newline at end of file