forked from naev/naev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattributes.h
74 lines (63 loc) · 1.67 KB
/
attributes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* See Licensing and Copyright notice in naev.h
*/
#pragma once
#ifndef __has_attribute
#define __has_attribute( x ) 0
#endif
// Nullability
#if __has_attribute( nonnull )
#define NONNULL( ... ) __attribute__( ( nonnull( __VA_ARGS__ ) ) )
#else
#define NONNULL( ... )
#endif
#if __has_attribute( returns_nonnull )
#define RETURNS_NONNULL __attribute__( ( returns_nonnull ) )
#else
#define RETURNS_NONNULL
#endif
// Function attributes
#if __has_attribute( sentinel )
#define SENTINEL( n ) __attribute__( ( sentinel( n ) ) )
#else
#define SENTINEL( n )
#endif
#if __has_attribute( noreturn )
#define NORETURN __attribute__( ( noreturn ) )
#else
#define NORETURN
#endif
#if __has_attribute( format )
#define FORMAT( ... ) __attribute__( ( format ( __VA_ARGS__ ) ) )
#else
#define FORMAT( ... )
#endif
#if __has_attribute( format_arg )
#define FORMAT_ARG( n ) __attribute__( ( format_arg ( n ) ) )
#else
#define FORMAT_ARG( n )
#endif
#if __has_attribute( deprecated )
#define DEPRECATED( msg ) __attribute__( ( deprecated( msg ) ) )
#else
#define DEPRECATED( msg )
#endif
#if __has_attribute( always_inline )
#define ALWAYS_INLINE __attribute__( ( always_inline ) )
#else
#define ALWAYS_INLINE
#endif
// User defined diagnosis
#if __has_attribute( diagnose_if )
#define WARN_IF( c, m ) __attribute__( ( diagnose_if( c, m, "warning" ) ) )
#define ERR_IF( c, m ) __attribute__( ( diagnose_if( c, m, "error" ) ) )
#else
#define WARN_IF( c, m )
#define ERR_IF( c, m )
#endif
// Statement attributes
#if __has_attribute( fallthrough )
#define FALLTHROUGH __attribute__( ( fallthrough ) )
#else
#define FALLTHROUGH (void)0
#endif