From 5e1288b8ef2ba3356256ca82b119e3abffad7b1b Mon Sep 17 00:00:00 2001 From: flagarde Date: Tue, 14 May 2024 13:54:23 +0800 Subject: [PATCH] Fix --- examples/CMakeLists.txt | 2 ++ include/Khaos/Version.h | 19 ++++++++++++++----- src/KhaosVersion.h.in | 12 +++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ac3dbe3..46ca3f3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,7 @@ add_executable(KhaosVersion.example KhaosVersion.cpp) target_link_libraries(KhaosVersion.example PRIVATE Khaos::Khaos) +add_test(NAME KhaosVersion.example COMMAND KhaosVersion.example) add_executable(Compiler.example Compiler.cpp) target_link_libraries(Compiler.example PRIVATE Khaos::Khaos) +add_test(NAME Compiler.example COMMAND Compiler.example) diff --git a/include/Khaos/Version.h b/include/Khaos/Version.h index bd4b494..7dc02a8 100644 --- a/include/Khaos/Version.h +++ b/include/Khaos/Version.h @@ -10,6 +10,11 @@ #ifndef KHAOS_VERSION_H_ #define KHAOS_VERSION_H_ +#if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + /*! * \file Version.h * \brief Define macros to set, get versions. @@ -43,7 +48,7 @@ * #define KHAOS_DEFINE_name_VERSION_PRIVATE() SET_VERSION(2,3,4,5) * \endcode */ -#define SET_VERSION(major, minor, patch, tweak) ((((major)*1UL % (1 << 16)) << 48) + (((minor)*1UL % (1 << 16)) << 32) + (((patch)*1UL % (1 << 16)) << 16) + ((tweak)*1UL % (1 << 16))) /* //NOSONAR */ +#define SET_VERSION(major, minor, patch, tweak) ((((major)*1ULL % (1 << 16)) << 48) + (((minor)*1ULL % (1 << 16)) << 32) + (((patch)*1ULL % (1 << 16)) << 16) + ((tweak)*1ULL % (1 << 16))) /* //NOSONAR */ /*! * \hideinitializer @@ -52,7 +57,7 @@ * * \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values. */ -#define GET_VERSION_MAJOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1UL) >> 48) % (1 << 16)) /* //NOSONAR */ +#define GET_VERSION_MAJOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 48) % (1 << 16)) /* //NOSONAR */ /*! * \hideinitializer @@ -61,7 +66,7 @@ * * \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values. */ -#define GET_VERSION_MINOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1UL) >> 32) % (1 << 16)) /* //NOSONAR */ +#define GET_VERSION_MINOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 32) % (1 << 16)) /* //NOSONAR */ /*! * \hideinitializer @@ -70,7 +75,7 @@ * * \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values. */ -#define GET_VERSION_PATCH(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1UL) >> 16) % (1 << 16)) /* //NOSONAR */ +#define GET_VERSION_PATCH(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 16) % (1 << 16)) /* //NOSONAR */ /*! * \hideinitializer @@ -79,6 +84,10 @@ * * \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values. */ -#define GET_VERSION_TWEAK(name) (((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1UL) % (1 << 16)) /* //NOSONAR */ +#define GET_VERSION_TWEAK(name) (((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) % (1 << 16)) /* //NOSONAR */ + +#if defined(__clang__) + #pragma clang diagnostic pop +#endif #endif /* KHAOS_VERSION_H_ */ diff --git a/src/KhaosVersion.h.in b/src/KhaosVersion.h.in index ac43734..e5c246f 100644 --- a/src/KhaosVersion.h.in +++ b/src/KhaosVersion.h.in @@ -26,6 +26,12 @@ #ifndef KHAOS_KHAOS_VERSION_H_ #define KHAOS_KHAOS_VERSION_H_ + +#if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + #include "Khaos/Version.h" /*! @@ -34,7 +40,11 @@ \note Use #GET_VERSION_MAJOR(Khaos), #GET_VERSION_MINOR(Khaos), #GET_VERSION_PATCH(Khaos) to parse it. */ /* clang-format off*/ -#define KHAOS_DEFINE_Khaos_VERSION_PRIVATE() SET_VERSION(@Khaos_VERSION_MAJOR@UL,@Khaos_VERSION_MINOR@UL,@Khaos_VERSION_PATCH@UL,@Khaos_VERSION_TWEAK@UL) +#define KHAOS_DEFINE_Khaos_VERSION_PRIVATE() SET_VERSION(@Khaos_VERSION_MAJOR@ULL,@Khaos_VERSION_MINOR@ULL,@Khaos_VERSION_PATCH@ULL,@Khaos_VERSION_TWEAK@ULL) /* clang-format on*/ +#if defined(__clang__) + #pragma clang diagnostic pop +#endif + #endif /* KHAOS_KHAOS_VERSION_H_*/