Skip to content

Commit

Permalink
Note compiler as an example
Browse files Browse the repository at this point in the history
Other tools *also* process C source code, e.g., linters and SAST tools.

Signed-off-by: David A. Wheeler <[email protected]>
  • Loading branch information
david-a-wheeler committed Oct 18, 2023
1 parent a8c5476 commit c5f5229
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ This warning flag warns when a fallthrough occurs unless it is specially marked

This warning flag does not have a performance impact. However, sometimes a fallthrough *is* intentional. This flag requires developers annotate those (rare) cases in the source code where a falthrough *is* intentional, to suppress the warning. Obviously, this annotation should *only* be used when it is intentional. C++17 (or later) code should simply use the attribute `[[fallthrough]]` as it is standard (remember to add `;` after it).

The C17 standard [^C2017] does not provide a mechanism to mark intentional fallthroughs. Different tools support different mechanisms for marking one, including attributes and comments in various forms. A portable way to mark one, used by the Linux kernel version 5.10 and later, is to define a keyword-like macro named `fallthrough` to mark an intentional fallthrough that automatically adjusts to the compiler format [^StackOverflowFallthrough]:
The C17 standard [^C2017] does not provide a mechanism to mark intentional fallthroughs. Different tools support different mechanisms for marking one, including attributes and comments in various forms. A portable way to mark one, used by the Linux kernel version 5.10 and later, is to define a keyword-like macro named `fallthrough` to mark an intentional fallthrough that automatically adjusts to the tool (e.g., compiler) format [^StackOverflowFallthrough]:

~~~~c
#if __has_attribute(__fallthrough__)
Expand Down

0 comments on commit c5f5229

Please sign in to comment.