]> eyrie.org Git - kerberos/krb5-strength.git/blob - portable/macros.h
Merge branch 'debian' into squeeze
[kerberos/krb5-strength.git] / portable / macros.h
1 /*
2  * Portability macros used in include files.
3  *
4  * The canonical version of this file is maintained in the rra-c-util package,
5  * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
6  *
7  * Written by Russ Allbery <eagle@eyrie.org>
8  *
9  * The authors hereby relinquish any claim to any copyright that they may have
10  * in this work, whether granted under contract or by operation of law or
11  * international treaty, and hereby commit to the public, at large, that they
12  * shall not, at any time in the future, seek to enforce any copyright in this
13  * work against any person or entity, or prevent any person or entity from
14  * copying, publishing, distributing or creating derivative works of this
15  * work.
16  */
17
18 #ifndef PORTABLE_MACROS_H
19 #define PORTABLE_MACROS_H 1
20
21 /*
22  * __attribute__ is available in gcc 2.5 and later, but only with gcc 2.7
23  * could you use the __format__ form of the attributes, which is what we use
24  * (to avoid confusion with other macros).
25  */
26 #ifndef __attribute__
27 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
28 #  define __attribute__(spec)   /* empty */
29 # endif
30 #endif
31
32 /*
33  * We use __alloc_size__, but it was only available in fairly recent versions
34  * of GCC.  Suppress warnings about the unknown attribute if GCC is too old.
35  * We know that we're GCC at this point, so we can use the GCC variadic macro
36  * extension, which will still work with versions of GCC too old to have C99
37  * variadic macro support.
38  */
39 #if !defined(__attribute__) && !defined(__alloc_size__)
40 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
41 #  define __alloc_size__(spec, args...) /* empty */
42 # endif
43 #endif
44
45 /*
46  * LLVM and Clang pretend to be GCC but don't support all of the __attribute__
47  * settings that GCC does.  For them, suppress warnings about unknown
48  * attributes on declarations.  This unfortunately will affect the entire
49  * compilation context, but there's no push and pop available.
50  */
51 #if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
52 # pragma GCC diagnostic ignored "-Wattributes"
53 #endif
54
55 /*
56  * BEGIN_DECLS is used at the beginning of declarations so that C++
57  * compilers don't mangle their names.  END_DECLS is used at the end.
58  */
59 #undef BEGIN_DECLS
60 #undef END_DECLS
61 #ifdef __cplusplus
62 # define BEGIN_DECLS    extern "C" {
63 # define END_DECLS      }
64 #else
65 # define BEGIN_DECLS    /* empty */
66 # define END_DECLS      /* empty */
67 #endif
68
69 #endif /* !PORTABLE_MACROS_H */