mirror of
https://gitlab.freedesktop.org/xorg/proto/xorgproto.git
synced 2025-12-20 03:30:25 +01:00
Xfuncproto: define _X_FALLTHROUGH for modern compilers
Can be used to tell the compiler that fallthrough between cases in a switch statement is intentional. Handles gcc >= 7 and clang >= 12 as well as all C23-compliant compilers. Bumps xproto version to 7.0.34. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/96>
This commit is contained in:
parent
9d5e1d1dc1
commit
1914233e66
2 changed files with 19 additions and 4 deletions
|
|
@ -78,13 +78,16 @@ in this Software without prior written authorization from The Open Group.
|
|||
|
||||
/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_attribute(x) 0 /* Compatibility with older compilers. */
|
||||
#endif
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_feature(x) 0 /* Compatibility with older compilers. */
|
||||
#endif
|
||||
#ifndef __has_extension
|
||||
# define __has_extension(x) 0 /* Compatibility with non-clang compilers. */
|
||||
# define __has_extension(x) 0 /* Compatibility with older compilers. */
|
||||
#endif
|
||||
#ifndef __has_c_attribute
|
||||
# define __has_c_attribute(x) 0 /* Compatibility with pre-C23 compilers. */
|
||||
#endif
|
||||
|
||||
/* Added in X11R6.9, so available in any version of modular xproto */
|
||||
|
|
@ -213,4 +216,16 @@ in this Software without prior written authorization from The Open Group.
|
|||
# define _X_NONSTRING
|
||||
#endif
|
||||
|
||||
/* Mark a fallthrough in a switch statement as intentional
|
||||
Handles C23 compilers, as well as gcc >= 7 and clang >= 12
|
||||
For older compilers/linters, pair with a fallthrough comment. */
|
||||
/* requires xproto >= 7.0.34 */
|
||||
#if __has_c_attribute(fallthrough)
|
||||
#define _X_FALLTHROUGH [[fallthrough]]
|
||||
#elif __has_attribute(fallthrough)
|
||||
#define _X_FALLTHROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
#define _X_FALLTHROUGH (void)0
|
||||
#endif
|
||||
|
||||
#endif /* _XFUNCPROTO_H_ */
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ includex11dir=@includedir@/X11
|
|||
|
||||
Name: Xproto
|
||||
Description: Xproto headers
|
||||
Version: 7.0.33
|
||||
Version: 7.0.34
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue