Skip to content

Commit

Permalink
Merge pull request #1181 from no92/static-asserts
Browse files Browse the repository at this point in the history
options/internal: fix static asserts for pre-C++03
  • Loading branch information
avdgrinten authored Oct 28, 2024
2 parents 1a53ea2 + 7accb84 commit ea90982
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions options/internal/include/bits/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,13 @@ typedef __SIZE_TYPE__ __mlibc_size;
/* Sanity checking. Make sure that we agree with the compiler's ABI. */
/* ---------------------------------------------------------------------------- */

#if defined(__cpp_static_assert)
#if defined(__cplusplus) && defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
# define __MLIBC_STATIC_ASSERT(c, text) static_assert(c, text)
#else
#elif !defined(__cplusplus)
/* _Static_assert is an extension in C89/C99. */
# define __MLIBC_STATIC_ASSERT(c, text) __extension__ _Static_assert(c, text)
#else
# define __MLIBC_STATIC_ASSERT(c, text) extern int __static_assert_unavailable
#endif

#define __MLIBC_CHECK_TYPE(T1, T2) __MLIBC_STATIC_ASSERT(sizeof(T1) == sizeof(T2),\
Expand Down

0 comments on commit ea90982

Please sign in to comment.