Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilersupport_p.h: add a macro for the fallthrough attribute #265

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cborparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static CborError preparse_value(CborValue *it)
case SinglePrecisionFloat:
case DoublePrecisionFloat:
it->flags |= CborIteratorFlag_IntegerValueTooLarge;
/* fall through */
CBOR_FALLTHROUGH;
case TrueValue:
case NullValue:
case UndefinedValue:
Expand Down
14 changes: 14 additions & 0 deletions src/compilersupport_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
#else
# define cbor_static_assert(x) ((void)sizeof(char[2*!!(x) - 1]))
#endif

#if defined(__has_cpp_attribute) // C23 and C++17
# if __has_cpp_attribute(fallthrough)
# define CBOR_FALLTHROUGH [[fallthrough]]
# endif
#endif
#ifndef CBOR_FALLTHROUGH
# ifdef __GNUC__
# define CBOR_FALLTHROUGH __attribute__((fallthrough))
# else
# define CBOR_FALLTHROUGH do { } while (0)
# endif
#endif

#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)
/* inline is a keyword */
#else
Expand Down
Loading