]> pd.if.org Git - pdclib/blob - internals/_PDCLIB_aux.h
* Change the style of inclusion of the internal/ headers. Modern preprocessors
[pdclib] / internals / _PDCLIB_aux.h
1 #ifndef _PDCLIB_AUX_H
2 #define _PDCLIB_AUX_H
3
4 /* Auxiliary PDCLib code <_PDCLIB_aux.h>
5
6    This file is part of the Public Domain C Library (PDCLib).
7    Permission is granted to use, modify, and / or redistribute at will.
8 */
9
10 /* -------------------------------------------------------------------------- */
11 /* You should not have to edit anything in this file; if you DO have to, it   */
12 /* would be considered a bug / missing feature: notify the author(s).         */
13 /* -------------------------------------------------------------------------- */
14
15 /* -------------------------------------------------------------------------- */
16 /* Standard Version                                                           */
17 /* -------------------------------------------------------------------------- */
18
19 /* Many a compiler gets this wrong, so you might have to hardcode it instead. */
20
21 #if __STDC__ != 1
22 #error Compiler does not define _ _STDC_ _ to 1 (not standard-compliant)!
23 #endif
24
25 #if defined(_PDCLIB_C_VERSION)
26         /* Pass - conditional simplification case */
27 #elif !defined(__STDC_VERSION__)
28         #define _PDCLIB_C_VERSION 1990
29 #elif __STDC_VERSION__ == 199409L
30         #define _PDCLIB_C_VERSION 1995
31 #elif __STDC_VERSION__ == 199901L
32         #define _PDCLIB_C_VERSION 1999
33 #elif __STDC_VERSION__ == 201112L
34         #define _PDCLIB_C_VERSION 2011
35 #else
36         #error Unsupported _ _STDC_VERSION_ _ (__STDC_VERSION__) (supported: ISO/IEC 9899:1990, 9899/AMD1:1995, 9899:1999, 9899:2011).
37 #endif
38
39 #if !defined(__cplusplus) || defined(_PDCLIB_CXX_VERSION)
40         /* Pass - conditional simplification case */
41 #elif __cplusplus == 201103L
42         #define _PDCLIB_CXX_VERSION 2011
43         #if _PDCLIB_C_VERSION < 2011
44                 #undef _PDCLIB_C_VERSION
45                 #define _PDCLIB_C_VERSION 2011
46         #endif
47 #elif __cplusplus == 199711L
48    #define _PDCLIB_CXX_VERSION 1997
49 #else
50    #error Unsupported _ _cplusplus (__cplusplus) (supported: ISO/IEC 14882:1997, ISO/IEC 14882:2011).
51 #endif
52
53 #if _PDCLIB_C_VERSION >= 1999 || defined(__cplusplus)
54         #ifndef __cplusplus
55                 #define _PDCLIB_restrict restrict
56         #endif
57         #define _PDCLIB_inline   inline
58 #endif
59
60 #if _PDCLIB_CXX_VERSION >= 2011
61         #define _PDCLIB_noreturn [[noreturn]]
62 #elif _PDCLIB_C_VERSION >= 2011
63         #define _PDCLIB_noreturn _Noreturn
64 #endif
65
66 #ifdef __GNUC__
67         #ifndef _PDCLIB_restrict
68                 #define _PDCLIB_restrict __restrict
69         #endif
70
71         #ifndef _PDCLIB_inline
72                 #define _PDCLIB_inline __inline
73         #endif
74
75         #ifndef _PDCLIB_noreturn
76                 #define _PDCLIB_noreturn __attribute__((noreturn))
77         #endif
78 #endif
79
80 #ifndef _PDCLIB_restrict
81         #define _PDCLIB_restrict
82 #endif
83
84 #ifndef _PDCLIB_inline
85         #define _PDCLIB_inline
86 #endif
87
88 #ifndef _PDCLIB_noreturn
89         #define _PDCLIB_noreturn
90 #endif
91
92 #ifndef __STDC_HOSTED__
93 #error Compiler does not define _ _STDC_HOSTED_ _ (not standard-compliant)!
94 #elif __STDC_HOSTED__ == 0
95 #define _PDCLIB_HOSTED 0
96 #elif __STDC_HOSTED__ == 1
97 #define _PDCLIB_HOSTED 1
98 #else
99 #error Compiler does not define _ _STDC_HOSTED_ _ to 0 or 1 (not standard-compliant)!
100 #endif
101
102 #ifdef __cplusplus
103         #define _PDCLIB_BEGIN_EXTERN_C extern "C" {
104         #define _PDCLIB_END_EXTERN_C }
105 #else
106    #define _PDCLIB_BEGIN_EXTERN_C
107    #define _PDCLIB_END_EXTERN_C
108 #endif
109
110 /*#if _PDCLIB_C_VERSION != 1999
111 #error PDCLib might not be fully conforming to either C89 or C95 prior to v2.x.
112 #endif*/
113
114 /* -------------------------------------------------------------------------- */
115 /* Helper macros:                                                             */
116 /* _PDCLIB_cc( x, y ) concatenates two preprocessor tokens without extending  */
117 /* _PDCLIB_concat( x, y ) concatenates two preprocessor tokens with extending */
118 /* -------------------------------------------------------------------------- */
119
120 #define _PDCLIB_cc( x, y )     x ## y
121 #define _PDCLIB_concat( x, y ) _PDCLIB_cc( x, y )
122
123 #define _PDCLIB_symbol2value( x ) #x
124 #define _PDCLIB_symbol2string( x ) _PDCLIB_symbol2value( x )
125
126 #ifndef __PDCLIB_PURE
127     #define __PDCLIB_PURE 0
128 #endif
129
130 #ifndef _PDCLIB_POSIX_EX
131     #define _PDCLIB_POSIX_EX (!__PDCLIB_PURE)
132 #endif
133 #endif