mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-19 08:50:25 +01:00
util: add a FALLTROUGH macro
Not all compilers support __atttribute__((fallthrough)) so use a macro. v2: use C++17 / C18 standard attribute (Tony Wasserka) Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> (v1) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7747>
This commit is contained in:
parent
a5b899c7da
commit
5e7c00aacb
1 changed files with 13 additions and 0 deletions
|
|
@ -72,5 +72,18 @@
|
|||
|
||||
#define IEEE_ONE 0x3f800000
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L || __STDC_VERSION__ >= 201710L
|
||||
/* Standard C++17/C18 attribute */
|
||||
#define FALLTHROUGH [[fallthrough]]
|
||||
#elif __has_attribute(fallthrough)
|
||||
/* Non-standard but supported by at least gcc and clang */
|
||||
#define FALLTHROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
#define FALLTHROUGH do { } while(0)
|
||||
#endif
|
||||
|
||||
#endif /* COMPILER_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue