|
38 | 38 | #define C_ENHANCED_H
|
39 | 39 |
|
40 | 40 |
|
41 |
| -//=//// EXPECTS <stdint.h> OR "pstdint.h" SHIM INCLUDED ///////////////////=// |
42 |
| -// |
43 |
| -// Rebol's initial design targeted C89 and old-ish compilers on a variety of |
44 |
| -// systems. A comment in that code said: |
45 |
| -// |
46 |
| -// "One of the biggest flaws in the C language was not |
47 |
| -// to indicate bitranges of integers. So, we do that here. |
48 |
| -// You cannot 'abstractly remove' the range of a number. |
49 |
| -// It is a critical part of its definition." |
50 |
| -// |
51 |
| -// Once C99 arrived, the file <stdint.h> offered several basic types, and |
52 |
| -// basically covered the needs: |
53 |
| -// |
54 |
| -// http://en.cppreference.com/w/c/types/integer |
55 |
| -// |
56 |
| -// The code was changed to use either the C99 types -or- a portable shim that |
57 |
| -// could mimic the types (with the same names) on older compilers. It should |
58 |
| -// be included before %c-enhanced.h is included. |
59 |
| -// |
60 |
| -//=////////////////////////////////////////////////////////////////////////=// |
61 |
| -// |
62 |
| -// Note: INT32_MAX and INT32_C can be missing in C++ builds on some older |
63 |
| -// compilers without __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS: |
64 |
| -// |
65 |
| -// https://sourceware.org/bugzilla/show_bug.cgi?id=15366 |
| 41 | +#if !defined(DEBUG_CHECK_OPTIONALS) |
| 42 | + #define DEBUG_CHECK_OPTIONALS 0 |
| 43 | +#endif |
| 44 | + |
| 45 | +#if !defined(DEBUG_CHECK_NEVERNULL) |
| 46 | + #define DEBUG_CHECK_NEVERNULL 0 |
| 47 | +#endif |
| 48 | + |
| 49 | + |
| 50 | +// Ren-C assumes the availability of <stdint.h> and <stdbool.h> |
66 | 51 | //
|
67 |
| -// You can run into this since pstdint.h falls back on stdint.h if it |
68 |
| -// thinks it can. Put those on the command line if needed. |
| 52 | +// If for some reason the only barrier to compiling the codebase is lack of |
| 53 | +// these definitions, there are shims on the Internet that implement them |
| 54 | +// (look for pstdint.h and pstdbool.h) But lack of variadic macros is likely |
| 55 | +// to be a bigger showstopper on older platforms. |
69 | 56 | //
|
70 |
| -// !!! One aspect of pstdint.h is that it considers 64-bit "optional". |
71 |
| -// Some esoteric platforms may have a more hidden form of 64-bit support, |
72 |
| -// e.g. this case from R3-Alpha for "Windows VC6 nonstandard typing": |
| 57 | +// * One aspect of pstdint.h is that it considers 64-bit "optional". |
| 58 | +// Some esoteric platforms may have a more hidden form of 64-bit support, |
| 59 | +// e.g. this case from R3-Alpha for "Windows VC6 nonstandard typing": |
73 | 60 | //
|
74 | 61 | // #if (defined(_MSC_VER) && (_MSC_VER <= 1200))
|
75 | 62 | // typedef _int64 i64;
|
|
78 | 65 | // #define U64_C(c) c ## U64
|
79 | 66 | // #endif
|
80 | 67 | //
|
81 |
| -// If %pstdint.h isn't trying hard enough for an unsupported platform of |
82 |
| -// interest to get 64-bit integers, then patches should be made there. |
| 68 | +// If %pstdint.h isn't trying hard enough for an unsupported platform of |
| 69 | +// interest to get 64-bit integers, then patches should be made there. |
83 | 70 | //
|
84 |
| - |
85 |
| -#if !defined(DEBUG_CHECK_OPTIONALS) |
86 |
| - #define DEBUG_CHECK_OPTIONALS 0 |
87 |
| -#endif |
88 |
| - |
89 |
| -#if !defined(DEBUG_CHECK_NEVERNULL) |
90 |
| - #define DEBUG_CHECK_NEVERNULL 0 |
91 |
| -#endif |
92 |
| - |
93 |
| - |
94 |
| -//=//// EXPECTS <stdbool.h> OR "pstdbool.h" SHIM INCLUDED /////////////////=// |
| 71 | +// * INT32_MAX and INT32_C can be missing in C++ builds on some older |
| 72 | +// compilers without __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS: |
95 | 73 | //
|
96 |
| -// Historically Rebol used TRUE and FALSE uppercase macros, but so long as |
97 |
| -// C99 has added bool to the language, there's not much point in being |
98 |
| -// compatible with codebases that have `char* true = "Spandau";` or similar |
99 |
| -// in them. So Rebol can use `true` and `false. |
| 74 | +// https://sourceware.org/bugzilla/show_bug.cgi?id=15366 |
100 | 75 | //
|
| 76 | +#include <stdint.h> |
| 77 | +#if !defined(__cplusplus) |
| 78 | + #include <stdbool.h> |
| 79 | +#endif |
101 | 80 |
|
102 | 81 |
|
103 | 82 | //=//// EXPECTS <assert.h> TO BE INCLUDED, PATCH BUG //////////////////////=//
|
|
182 | 161 |
|
183 | 162 | //=//// CPLUSPLUS_11 PREPROCESSOR DEFINE //////////////////////////////////=//
|
184 | 163 | //
|
185 |
| -// Because the goal of Ren-C is ultimately to be built with C, the C++ build |
186 |
| -// is just for static analysis and debug checks. This means there's not much |
187 |
| -// value in trying to tailor reduced versions of the checks to old ANSI C++98 |
188 |
| -// compilers, so the "C++ build" is an "at least C++11 build". |
| 164 | +// Because the goal of Ren-C is generally to be buildable as C, the C++ build |
| 165 | +// is mostly for static analysis and debug checks. (But also exceptions with |
| 166 | +// try/catch, on platforms where setjmp()/longjmp() are not viable.) |
| 167 | +// |
| 168 | +// There's not much value in trying to tailor reduced versions of the checks |
| 169 | +// to ANSI C++98 compilers, so the "C++ build" is an "at least C++11 build". |
189 | 170 | //
|
190 | 171 | // Besides being a little less verbose to use, testing via a #define allows
|
191 | 172 | // override when using with Microsoft Visual Studio via a command line
|
|
0 commit comments