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
Support compiler-agnostic annotations #2456
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* This file and its contents are licensed under the Apache License 2.0. | ||
* Please see the included NOTICE for copyright information and | ||
* LICENSE-APACHE for a copy of the license. | ||
*/ | ||
#ifndef TIMESCALEDB_ANNOTATIONS_H | ||
#define TIMESCALEDB_ANNOTATIONS_H | ||
|
||
/* Fall-through annotation */ | ||
#if defined(__clang__) | ||
#if (__clang_major__ >= 12) || (__clang_analyzer__) | ||
#define TS_FALLTHROUGH __attribute__((fallthrough)) | ||
#else | ||
#define TS_FALLTHROUGH /* FALLTHROUGH */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing that worries me here is that both comments and macros symbols are handled by the preprocessor. Have you tested this with a compiler that uses the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We used the |
||
#endif /* __clang__ */ | ||
#elif defined(__GNUC__) | ||
/* Supported since GCC 7 */ | ||
#define TS_FALLTHROUGH __attribute__((fallthrough)) | ||
#else | ||
/* MSVC and other compilers */ | ||
#define TS_FALLTHROUGH /* FALLTHROUGH */ | ||
#endif | ||
|
||
#endif /* TIMESCALEDB_ANNOTATIONS_H */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to note that it is also possible to write /
* fallthough */
comment which will be recognized, maybe it could be easier to support in some senseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the issue. It seems to no longer be supported in clang 12 (at least on the mac)