]> pd.if.org Git - pdclib/blob - internals/_PDCLIB_aux.h
Various updates. Made assert() no longer rely on standard version. Removed _PDCLIB_C_...
[pdclib] / internals / _PDCLIB_aux.h
1 /* Auxiliary PDCLib code <_PDCLIB_aux.h>
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #ifndef _PDCLIB_AUX_H
8 #define _PDCLIB_AUX_H _PDCLIB_AUX_H
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 __STDC_VERSION__ < 199901L
26 #define _PDCLIB_restrict
27 #define _PDCLIB_inline
28 #error PDCLib might not be fully conforming to either C89 or C95 prior to v2.x.
29 #else
30 #define _PDCLIB_restrict restrict
31 #define _PDCLIB_inline inline
32 #endif
33
34 #ifndef __STDC_HOSTED__
35 #error Compiler does not define _ _STDC_HOSTED_ _ (not standard-compliant)!
36 #elif __STDC_HOSTED__ == 0
37 #define _PDCLIB_HOSTED 0
38 #elif __STDC_HOSTED__ == 1
39 #define _PDCLIB_HOSTED 1
40 #else
41 #error Compiler does not define _ _STDC_HOSTED_ _ to 0 or 1 (not standard-compliant)!
42 #endif
43
44 /* -------------------------------------------------------------------------- */
45 /* Helper macros:                                                             */
46 /* _PDCLIB_cc( x, y ) concatenates two preprocessor tokens without extending  */
47 /* _PDCLIB_concat( x, y ) concatenates two preprocessor tokens with extending */
48 /* _PDCLIB_static_assert( e, m ) does a compile-time assertion of expression  */
49 /*                               e, with m as the failure message.            */
50 /* -------------------------------------------------------------------------- */
51
52 #define _PDCLIB_cc( x, y )     x ## y
53 #define _PDCLIB_concat( x, y ) _PDCLIB_cc( x, y )
54
55 #define _PDCLIB_static_assert( e, m ) enum { _PDCLIB_concat( _PDCLIB_assert_, __LINE__ ) = 1 / ( !!(e) ) }
56
57 #define _PDCLIB_symbol2value( x ) #x
58 #define _PDCLIB_symbol2string( x ) _PDCLIB_symbol2value( x )
59
60 #endif