summaryrefslogtreecommitdiff
path: root/include/attributes.h
blob: 69ce0b9f42a774e77d4b1e92a9ddb908fdb850eb (plain)
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
#ifndef ATTRIBUTES_H
#define ATTRIBUTES_H


#if (!defined(__GNUC__) && !defined(__clang__)) || defined(M2CTX) || defined(__sgi)
    #ifndef __attribute__
        #define __attribute__(x)
    #endif
#endif


#ifndef FALLTHROUGH
    #ifdef PERMUTER
        #define FALLTHROUGH
    #elif __STDC_VERSION__ >= 202000L
        #define FALLTHROUGH [[fallthrough]]
    #else
        #define FALLTHROUGH __attribute__((fallthrough))
    #endif
#endif

#ifndef NORETURN
    #ifdef PERMUTER
        #define NORETURN
    #elif __STDC_VERSION__ >= 202000L
        #define NORETURN [[noreturn]]
    #elif __STDC_VERSION__ >= 201112L
        #define NORETURN _Noreturn
    #else
        #define NORETURN __attribute__((noreturn))
    #endif
#endif

#ifndef UNUSED
    #ifdef PERMUTER
        #define UNUSED
    #elif __STDC_VERSION__ >= 202000L
        #define UNUSED [[maybe_unused]]
    #else
        #define UNUSED __attribute__((unused))
    #endif
#endif


#endif