-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support compiler-agnostic annotations
This change adds a compiler-agnostic annotation for fall-throughs in switch statements. The definition is put in `annotations.h`, which can be expanded to hold definitions for similar functionality in the future. The `clang` compiler (as of version 12) seems to have have dropped support for the previous comment-based annotations to allow fall-throughs in favor of native annotations or GCC-style attributes.
- Loading branch information
Showing
8 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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 */ | ||
#endif /* __clang__ */ | ||
#elif defined(__GNUC__) | ||
/* Supported since GCC 7 */ | ||
#define TS_FALLTHROUGH __attribute__((fallthrough)) | ||
#elif defined(_MSC_VER) | ||
#define TS_FALLTHROUGH /* FALLTHROUGH */ | ||
#else | ||
#error "unsupported compiler" | ||
#endif | ||
|
||
#endif /* TIMESCALEDB_ANNOTATIONS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters