Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed May 14, 2024
1 parent 9d92cf5 commit 7a7e376
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions include/Khaos/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
* \endcode
*/

#if defined(__clang__)
#define KHAOS_PUSH_WARNING_CXX98_COMPAT_PEDANTIC() _Pragma("clang diagnostic push")_Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"")
#define KHAOS_POP_WARNING_CXX98_COMPAT_PEDANTIC() _Pragma("clang diagnostic pop")
#else
#define KHAOS_PUSH_WARNING_CXX98_COMPAT_PEDANTIC()
#define KHAOS_POP_WARNING_CXX98_COMPAT_PEDANTIC()
#endif

/*!
* \hideinitializer
* \brief Set standard version numbers.
Expand All @@ -43,7 +51,7 @@
* #define KHAOS_DEFINE_name_VERSION_PRIVATE() SET_VERSION(2,3,4,5)
* \endcode
*/
#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 */
#define SET_VERSION(major, minor, patch, tweak) (KHAOS_PUSH_WARNING_CXX98_COMPAT_PEDANTIC()(((major)*1ULL % (1 << 16)) << 48) + (((minor)*1ULL % (1 << 16)) << 32) + (((patch)*1ULL % (1 << 16)) << 16) + ((tweak)*1ULL % (1 << 16))KHAOS_POP_WARNING_CXX98_COMPAT_PEDANTIC()) /* //NOSONAR */

/*!
* \hideinitializer
Expand All @@ -52,7 +60,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()) * 1ULL) >> 48) % (1 << 16)) /* //NOSONAR */
#define GET_VERSION_MAJOR(name) (KHAOS_PUSH_WARNING_CXX98_COMPAT_PEDANTIC()(((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 48) % (1 << 16)KHAOS_POP_WARNING_CXX98_COMPAT_PEDANTIC()) /* //NOSONAR */

/*!
* \hideinitializer
Expand All @@ -61,7 +69,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()) * 1ULL) >> 32) % (1 << 16)) /* //NOSONAR */
#define GET_VERSION_MINOR(name) (KHAOS_PUSH_WARNING_CXX98_COMPAT_PEDANTIC()(((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 32) % (1 << 16)KHAOS_POP_WARNING_CXX98_COMPAT_PEDANTIC()) /* //NOSONAR */

/*!
* \hideinitializer
Expand All @@ -70,7 +78,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()) * 1ULL) >> 16) % (1 << 16)) /* //NOSONAR */
#define GET_VERSION_PATCH(name) (KHAOS_PUSH_WARNING_CXX98_COMPAT_PEDANTIC()(((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 16) % (1 << 16)KHAOS_POP_WARNING_CXX98_COMPAT_PEDANTIC()) /* //NOSONAR */

/*!
* \hideinitializer
Expand All @@ -79,6 +87,6 @@
*
* \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()) * 1ULL) % (1 << 16)) /* //NOSONAR */
#define GET_VERSION_TWEAK(name) (KHAOS_PUSH_WARNING_CXX98_COMPAT_PEDANTIC()((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) % (1 << 16)KHAOS_POP_WARNING_CXX98_COMPAT_PEDANTIC()) /* //NOSONAR */

#endif /* KHAOS_VERSION_H_ */
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ endif()
add_library(KhaosTestFlags INTERFACE)

target_compile_options(KhaosTestFlags INTERFACE
$<$<CXX_COMPILER_ID:Clang>:-Wall -Weverything -pedantic -Wnoc++98-compat-pedantic>
$<$<CXX_COMPILER_ID:Clang>:-Wall -Weverything -pedantic>
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>
$<$<CXX_COMPILER_ID:Intel>:-Wall -Wextra -pedantic>
$<$<CXX_COMPILER_ID:IntelLLVM>:-Wall -Wextra -pedantic>
$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<C_COMPILER_ID:Clang>:-Wall -Weverything -pedantic -Wnoc++98-compat-pedantic>
$<$<C_COMPILER_ID:Clang>:-Wall -Weverything -pedantic>
$<$<C_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>
$<$<C_COMPILER_ID:IntelLLVM>:-Wall -Wextra -pedantic>
$<$<C_COMPILER_ID:Intel>:-Wall -Wextra -pedantic>
Expand Down

0 comments on commit 7a7e376

Please sign in to comment.