Skip to content

Commit 4885126

Browse files
compat: Use standard bool to resolve C99+ keyword conflicts (#18)
* compat: Use standard bool to resolve C99+ keyword conflicts * Fix style. --------- Co-authored-by: Wojciech Graj <[email protected]>
1 parent dd07b14 commit 4885126

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/doomtype.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,20 @@
6565

6666
#include <inttypes.h>
6767

68-
#ifdef __cplusplus
69-
70-
// Use builtin bool type with C++.
71-
72-
typedef bool bool;
73-
68+
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)
69+
// For C99+ and C++, use the standard boolean type
70+
#include <stdbool.h>
7471
#else
75-
76-
typedef enum
77-
{
78-
false = 0,
79-
true = 1,
80-
undef = 0xFFFFFFFF
81-
} bool;
82-
72+
// For older C standards, use the original custom enum
73+
typedef enum { false = 0, true = 1 } bool;
8374
#endif
8475

76+
// The original enum also defined an 'undef' state.
77+
// left for compatibility
78+
enum {
79+
undef = 0xFFFFFFFF
80+
};
81+
8582
typedef uint8_t byte;
8683

8784
#include <limits.h>

0 commit comments

Comments
 (0)