Skip to content

Commit 76d7a29

Browse files
florolfthiagomacieira
authored andcommitted
compilersupport: fix build with GCC < 11
Commit 45e4641 ("Fix build with GCC < 11: [[fallthrough]] is supported but not allowed in C") introduced a fix for old GCC versions, but commit 91d1c50 ("compilersupport: fix compilation in C23 mode") reverted it, reintroducing the build failure. Revert the revert. Signed-off-by: Florian Larysch <fl@n621.de>
1 parent c2c569f commit 76d7a29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/compilersupport_p.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@
5252
# define cbor_static_assert(x) ((void)sizeof(char[2*!!(x) - 1]))
5353
#endif
5454

55-
#if defined(__has_cpp_attribute) // C23 and C++17
55+
#if defined(__has_cpp_attribute) && defined(__cplusplus) // C++17
5656
# if __has_cpp_attribute(fallthrough)
5757
# define CBOR_FALLTHROUGH [[fallthrough]]
5858
# endif
59+
#elif defined(__has_c_attribute) && !defined(__cplusplus) // C23
60+
# if __has_c_attribute(fallthrough)
61+
# define CBOR_FALLTHROUGH [[fallthrough]]
62+
# endif
5963
#endif
6064
#ifndef CBOR_FALLTHROUGH
6165
# ifdef __GNUC__

0 commit comments

Comments
 (0)