Skip to content

Commit 51e0e77

Browse files
gyrovorbisQuzarDC
authored andcommitted
Removed #define for static_assert in C23.
1) assert.h - Adding another conditional check for C language revisions being less than or equal to C17 before defining the static_assert macro. - C23 introduced static_assert as a builtin keyword and no longer requires <assert.h> inclusion in order to use it. Furthemore, it deprecates the _Static_assert builtin we were defining it to.
1 parent a1ca20b commit 51e0e77

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

include/assert.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ __BEGIN_DECLS
4141
/** \cond */
4242
#define _assert(e) assert(e)
4343

44-
#if __STDC_VERSION__ >= 201112L && !defined __cplusplus
45-
#define static_assert _Static_assert
44+
/* 1) C11-C17: _Static_assert is a reserved word, and <assert.h> adds a macro,
45+
static_assert which maps to it.
46+
2) C23+: static_assert becomes a reserved word, _Static_assert becomes deprecated.
47+
3) C++11+: static_assert is a reserved word.
48+
*/
49+
#if __STDC_VERSION__ >= 201112L && __STDC_VERSION__ <= 201710L && !defined __cplusplus
50+
# define static_assert _Static_assert
4651
#endif
4752
/** \endcond */
4853

0 commit comments

Comments
 (0)