From ac12b5fbcd7878a01a0900d24383a65edc0e210f Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller Date: Mon, 16 Mar 2026 07:59:26 +0100 Subject: [PATCH] Fix compiler warnings found with Clang 22 - Use `__LINE__` instead of `__COUNTER__` since it is standard C++. This would only be problematic if the macro where they are used would happen multiple times in the same line, but since this is only being used in a .cc file and not in headers it should be safe. - Make Catch2 headers be part of the system include directories so that warnings from Catch2 are silenced when it is coming from the stack or the system --- include/podio/LinkCollection.h | 4 ++-- tests/unittests/CMakeLists.txt | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/podio/LinkCollection.h b/include/podio/LinkCollection.h index 81598e87d..3fccbf5d1 100644 --- a/include/podio/LinkCollection.h +++ b/include/podio/LinkCollection.h @@ -11,14 +11,14 @@ /// Main macro for declaring links. Takes care of registering the necessary /// buffer creation functionality with the CollectionBufferFactory. #define PODIO_DECLARE_LINK(FromT, ToT) \ - const static auto PODIO_PP_CONCAT(REGISTERED_LINK_, __COUNTER__) = \ + const static auto PODIO_PP_CONCAT(REGISTERED_LINK_, __LINE__) = \ podio::detail::registerLinkCollection(podio::LinkCollection::typeName); #if PODIO_ENABLE_SIO && __has_include("podio/detail/LinkSIOBlock.h") #include /// Macro for registering the necessary SIOBlock for a Link with the SIOBlock factory #define PODIO_DECLARE_LINK_SIO(FromT, ToT) \ - const static auto PODIO_PP_CONCAT(LINK_SIO_BLOCK_, __COUNTER__) = podio::LinkSIOBlock{}; + const static auto PODIO_PP_CONCAT(LINK_SIO_BLOCK_, __LINE__) = podio::LinkSIOBlock{}; #endif #endif // PODIO_LINKCOLLECTION_H diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index f3487a16c..6f595b2ec 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -33,11 +33,20 @@ if(NOT Catch2_FOUND) # Reset the flags set(CMAKE_CXX_FLAGS ${CXX_FLAGS_CMAKE_USED}) +else() + # Same hack as above for the system-installed Catch2: mark its include + # directories as SYSTEM to suppress warnings from Catch2 headers + get_target_property(CATCH2_IF_INC_DIRS Catch2::Catch2 INTERFACE_INCLUDE_DIRECTORIES) + set_target_properties(Catch2::Catch2 PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CATCH2_IF_INC_DIRS}") endif() find_package(Threads REQUIRED) add_executable(unittest_podio unittest.cpp frame.cpp buffer_factory.cpp interface_types.cpp std_interoperability.cpp links.cpp) target_link_libraries(unittest_podio PUBLIC TestDataModel ExtensionDataModel InterfaceExtensionDataModel PRIVATE Catch2::Catch2WithMain Threads::Threads podio::podioRootIO) +# Catch2 TEST_CASE/SECTION macros expand __COUNTER__ at the call site in user +# code, so marking Catch2 headers as system includes is not sufficient to +# suppress this warning, present with Clang 22 +target_compile_options(unittest_podio PRIVATE -Wno-c2y-extensions) if (ENABLE_SIO) target_link_libraries(unittest_podio PRIVATE podio::podioSioIO) endif()