Skip to content

Commit

Permalink
Fix msvc macro shit
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed May 7, 2024
1 parent 71617b4 commit 4e7cdaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/libassert/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ namespace libassert::detail {
#pragma warning(pop)
#endif

#if LIBASSERT_IS_CLANG || LIBASSERT_IS_GCC || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL == 0)
#if LIBASSERT_IS_CLANG || LIBASSERT_IS_GCC || !LIBASSERT_NON_CONFORMANT_MSVC_PREPROCESSOR
// Macro mapping utility by William Swanson https://github.com/swansontec/map-macro/blob/master/map.h
#define LIBASSERT_EVAL0(...) __VA_ARGS__
#define LIBASSERT_EVAL1(...) LIBASSERT_EVAL0(LIBASSERT_EVAL0(LIBASSERT_EVAL0(__VA_ARGS__)))
Expand Down Expand Up @@ -1719,7 +1719,7 @@ namespace libassert {
// non-prefixed versions

#ifndef LIBASSERT_PREFIX_ASSERTIONS
#if LIBASSERT_IS_CLANG || LIBASSERT_IS_GCC || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL == 0)
#if LIBASSERT_IS_CLANG || LIBASSERT_IS_GCC || !LIBASSERT_NON_CONFORMANT_MSVC_PREPROCESSOR
#define DEBUG_ASSERT(...) LIBASSERT_DEBUG_ASSERT(__VA_ARGS__)
#define ASSERT(...) LIBASSERT_ASSERT(__VA_ARGS__)
#define ASSUME(...) LIBASSERT_ASSUME(__VA_ARGS__)
Expand Down
15 changes: 10 additions & 5 deletions include/libassert/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,18 @@
#define LIBASSERT_GCC_ISNT_STUPID 1
#endif

#if defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL
#define LIBASSERT_NON_CONFORMANT_MSVC_PREPROCESSOR true
#else
#define LIBASSERT_NON_CONFORMANT_MSVC_PREPROCESSOR false
#endif

#if LIBASSERT_IS_GCC || LIBASSERT_STD_VER >= 20
// __VA_OPT__ needed for GCC, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44317
#define LIBASSERT_VA_ARGS(...) __VA_OPT__(,) __VA_ARGS__
#if (LIBASSERT_IS_GCC || LIBASSERT_STD_VER >= 20) && !LIBASSERT_NON_CONFORMANT_MSVC_PREPROCESSOR
// __VA_OPT__ needed for GCC, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44317
#define LIBASSERT_VA_ARGS(...) __VA_OPT__(,) __VA_ARGS__
#else
// clang properly eats the comma with ##__VA_ARGS__
#define LIBASSERT_VA_ARGS(...) , ##__VA_ARGS__
// clang properly eats the comma with ##__VA_ARGS__
#define LIBASSERT_VA_ARGS(...) , ##__VA_ARGS__
#endif


Expand Down

0 comments on commit 4e7cdaa

Please sign in to comment.