mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-11-18 10:24:04 +01:00
Fixed warnings on Windows (#407)
Now builds clean on MSVC: cl version 19.51.36260 for x64, from Visual Studio 2026 Build Tools 18.10.3. Major items: - [[maybe_unused]] instead of gcc/clang specific pragmas - Removed names variables that weren't used - Cast + explicit uing64
This commit is contained in:
1 parent
7e1b8a765d
commit
cdd8586f64
15 files changed
+47
-91
No files matched your search
@@ -208,6 +208,11 @@ if(AARE_FETCH_FMT)
|
||||
CACHE BOOL "")
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
if(MSVC)
|
||||
# fmt 12.1.0 calls std::isalpha only to check that ADL finds it and drops
|
||||
# the result, which MSVC's standard library marks [[nodiscard]]
|
||||
target_compile_options(fmt PRIVATE /wd4834)
|
||||
endif()
|
||||
else()
|
||||
find_package(fmt 8 REQUIRED)
|
||||
endif()
|
||||
|
||||
@@ -19,7 +19,7 @@ T string_to(const std::string &t, const std::string &unit) {
|
||||
double tval{0};
|
||||
try {
|
||||
tval = std::stod(t);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
throw std::runtime_error("Could not convert string to time");
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,6 @@ namespace py = pybind11;
|
||||
|
||||
using namespace aare;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
template <typename Type, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
typename CoordType>
|
||||
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
|
||||
@@ -20,9 +20,6 @@ namespace py = pybind11;
|
||||
|
||||
using namespace aare;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
template <typename T, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
typename CoordType = uint16_t>
|
||||
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
|
||||
@@ -13,11 +13,6 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
// 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<ClusterType> &self) { return &self; })
|
||||
.def("__exit__",
|
||||
[](ClusterFile<ClusterType> &self,
|
||||
const std::optional<pybind11::type> &exc_type,
|
||||
const std::optional<pybind11::object> &exc_value,
|
||||
const std::optional<pybind11::object> &traceback) {
|
||||
self.close();
|
||||
})
|
||||
[[maybe_unused]] const std::optional<pybind11::type> &exc_type,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&exc_value,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&traceback) { self.close(); })
|
||||
.def("__iter__", [](ClusterFile<ClusterType> &self) { return &self; })
|
||||
.def("__next__",
|
||||
[](File &self) { return ChunkIterator(self.chunks()).next(); });
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -17,9 +17,6 @@
|
||||
namespace py = pybind11;
|
||||
using namespace aare;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
template <typename T, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
typename CoordType = uint16_t>
|
||||
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<ClusterType>::stop);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -20,9 +20,6 @@ namespace py = pybind11;
|
||||
|
||||
using namespace aare;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
template <typename T, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
typename CoordType = uint16_t>
|
||||
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
|
||||
@@ -20,9 +20,6 @@ namespace py = pybind11;
|
||||
|
||||
using namespace aare;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
template <typename T, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
typename CoordType = uint16_t>
|
||||
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<ClusterType, uint16_t, pd_type> &self) {
|
||||
[]([[maybe_unused]] ClusterFinderMT<ClusterType, uint16_t, pd_type>
|
||||
&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
|
||||
@@ -18,9 +18,6 @@ namespace py = pybind11;
|
||||
|
||||
using namespace aare;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
template <typename Type, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
typename CoordType = uint16_t>
|
||||
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<ClusterType> &self) {
|
||||
[typestr]([[maybe_unused]] ClusterVector<ClusterType> &self) {
|
||||
return fmt_format<ClusterType>();
|
||||
},
|
||||
"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
|
||||
+7
-11
@@ -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<pybind11::type> &exc_type,
|
||||
const std::optional<pybind11::object> &exc_value,
|
||||
const std::optional<pybind11::object> &traceback) {
|
||||
[]([[maybe_unused]] File &self,
|
||||
[[maybe_unused]] const std::optional<pybind11::type> &exc_type,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&exc_value,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&traceback) {
|
||||
// self.close();
|
||||
})
|
||||
.def("__iter__", [](File &self) { return &self; })
|
||||
@@ -146,7 +144,7 @@ void define_file_io_bindings(py::module &m) {
|
||||
self.read_into(
|
||||
reinterpret_cast<std::byte *>(image.mutable_data()));
|
||||
return image;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (std::runtime_error &) {
|
||||
throw py::stop_iteration();
|
||||
}
|
||||
});
|
||||
@@ -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
|
||||
}
|
||||
@@ -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<JungfrauDataHeader> header(1);
|
||||
py::array_t<uint16_t> image({self.rows(), self.cols()});
|
||||
@@ -94,20 +89,20 @@ void define_jungfrau_data_file_io_bindings(py::module &m) {
|
||||
)")
|
||||
.def("__enter__", [](JungfrauDataFile &self) { return &self; })
|
||||
.def("__exit__",
|
||||
[](JungfrauDataFile &self,
|
||||
const std::optional<pybind11::type> &exc_type,
|
||||
const std::optional<pybind11::object> &exc_value,
|
||||
const std::optional<pybind11::object> &traceback) {
|
||||
[]([[maybe_unused]] JungfrauDataFile &self,
|
||||
[[maybe_unused]] const std::optional<pybind11::type> &exc_type,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&exc_value,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&traceback) {
|
||||
// self.close();
|
||||
})
|
||||
.def("__iter__", [](JungfrauDataFile &self) { return &self; })
|
||||
.def("__next__", [](JungfrauDataFile &self) {
|
||||
try {
|
||||
return read_dat_frame(self);
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (std::runtime_error &) {
|
||||
throw py::stop_iteration();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -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_<RawSubFile>(m, "RawSubFile")
|
||||
.def(py::init<const std::filesystem::path &, DetectorType, size_t,
|
||||
@@ -89,17 +84,18 @@ void define_raw_sub_file_io_bindings(py::module &m) {
|
||||
})
|
||||
.def("__enter__", [](RawSubFile &self) { return &self; })
|
||||
.def("__exit__",
|
||||
[](RawSubFile &self, const std::optional<pybind11::type> &exc_type,
|
||||
const std::optional<pybind11::object> &exc_value,
|
||||
const std::optional<pybind11::object> &traceback) {})
|
||||
[]([[maybe_unused]] RawSubFile &self,
|
||||
[[maybe_unused]] const std::optional<pybind11::type> &exc_type,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&exc_value,
|
||||
[[maybe_unused]] const std::optional<pybind11::object>
|
||||
&traceback) {})
|
||||
.def("__iter__", [](RawSubFile &self) { return &self; })
|
||||
.def("__next__", [](RawSubFile &self) {
|
||||
try {
|
||||
return read_frame_from_RawSubFile(self);
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (std::runtime_error &) {
|
||||
throw py::stop_iteration();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -221,7 +221,7 @@ JungfrauDataHeader JungfrauDataFile::read_header() {
|
||||
throw std::runtime_error(LOCATION + "Could not read header from file" +
|
||||
m_fp.error_msg());
|
||||
}
|
||||
m_fp.seek(-header_size, SEEK_CUR);
|
||||
m_fp.seek(-static_cast<ssize_t>(header_size), SEEK_CUR);
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ RawFileNameComponents::RawFileNameComponents(
|
||||
try {
|
||||
auto pos = m_base_name.rfind('_');
|
||||
m_file_index = std::stoi(m_base_name.substr(pos + 1));
|
||||
} catch (const std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
throw std::runtime_error(LOCATION + "Could not parse file index");
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ void RawMasterFile::parse_json(std::istream &is) {
|
||||
|
||||
try {
|
||||
m_quad = j.at("Quad");
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
// keep the optional empty
|
||||
}
|
||||
// try{
|
||||
@@ -384,7 +384,7 @@ void RawMasterFile::parse_json(std::istream &is) {
|
||||
if (digital_flag) {
|
||||
m_digital_samples = j.at("Digital Samples");
|
||||
}
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
// keep the optional empty
|
||||
}
|
||||
try {
|
||||
@@ -393,7 +393,7 @@ void RawMasterFile::parse_json(std::istream &is) {
|
||||
if (m_transceiver_flag) {
|
||||
m_transceiver_samples = j.at("Transceiver Samples");
|
||||
}
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
// keep the optional empty
|
||||
}
|
||||
try {
|
||||
@@ -414,7 +414,7 @@ void RawMasterFile::parse_json(std::istream &is) {
|
||||
m_scan_parameters
|
||||
.increment_stop(); // adjust for endpoint being included
|
||||
}
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
// not a scan
|
||||
}
|
||||
try {
|
||||
@@ -424,7 +424,7 @@ void RawMasterFile::parse_json(std::istream &is) {
|
||||
m_udp_port_types.value().push_back(
|
||||
string_to<UDPPortPosition>(elem));
|
||||
}
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
// leave the optional empty
|
||||
}
|
||||
try {
|
||||
@@ -433,13 +433,13 @@ void RawMasterFile::parse_json(std::istream &is) {
|
||||
for (auto &elem : json_list_obj) {
|
||||
m_disabled_udp_ports.push_back(static_cast<size_t>(elem));
|
||||
}
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
m_disabled_udp_ports
|
||||
.clear(); // empty list if not present in master file
|
||||
}
|
||||
try {
|
||||
m_udp_interfaces_per_module = {j.at("Number of UDP Interfaces"), 1};
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
if (m_type == DetectorType::Eiger && m_quad == 1)
|
||||
m_udp_interfaces_per_module = {2, 1};
|
||||
else if (m_type == DetectorType::Eiger) {
|
||||
@@ -485,7 +485,7 @@ void RawMasterFile::parse_json(std::istream &is) {
|
||||
}
|
||||
}
|
||||
|
||||
} catch (const json::out_of_range &e) {
|
||||
} catch (const json::out_of_range &) {
|
||||
// fill ROI with full detector size if not present in master file
|
||||
m_rois.push_back(
|
||||
{0, m_detector_layout.col * static_cast<ssize_t>(m_pixels_x), 0,
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ TEST_CASE("test_adc_sar_05_decode64to16") {
|
||||
// test all bits by iteratting through the bitlist
|
||||
std::vector<int> bitlist = {29, 19, 28, 18, 31, 21, 27, 20, 24, 23, 25, 22};
|
||||
for (size_t i = 0; i < bitlist.size(); i++) {
|
||||
input = 1UL << bitlist[i];
|
||||
input = 1ULL << bitlist[i];
|
||||
output = aare::adc_sar_05_decode64to16(input);
|
||||
CHECK(output == (1 << i));
|
||||
}
|
||||
@@ -95,7 +95,7 @@ TEST_CASE("Each byte buffer decoder maps to its own bit order") {
|
||||
};
|
||||
|
||||
for (const auto &c : cases) {
|
||||
uint64_t word = (1UL << c.bit0) | (1UL << c.bit1);
|
||||
uint64_t word = (1ULL << c.bit0) | (1ULL << c.bit1);
|
||||
std::vector<uint8_t> buffer(8);
|
||||
std::memcpy(buffer.data(), &word, sizeof(word));
|
||||
aare::NDView<const uint8_t, 2> bytes(buffer.data(), {1, 8});
|
||||
|
||||
Reference in new issue
Block a user