Skip to content

Commit

Permalink
more portable solution for true/false and qboolean issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed May 7, 2024
1 parent ede7dd0 commit 597c204
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions Quake/q_stdinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,23 @@ COMPILE_TIME_ASSERT(enum, sizeof(THE_DUMMY_ENUM) == sizeof(int));

typedef unsigned char byte;

#undef true
#undef false
#if defined(__cplusplus)
/* some structures have qboolean members and the x86 asm code expect
* those members to be 4 bytes long. therefore, qboolean must be 32
* bits and it can NOT be binary compatible with the 8 bit C++ bool. */
* those members to be 4 bytes long. i.e.: qboolean must be 32 bits. */
typedef int qboolean;
COMPILE_TIME_ASSERT(falsehood, (0 == false));
COMPILE_TIME_ASSERT(truth, (1 == true));
#else
#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
typedef int qboolean; /* C23: true/false are keywords. */
#undef true
#undef false
#if !defined(__cplusplus)
#if defined __STDC_VERSION__ && (__STDC_VERSION__ >= 199901L)
#include <stdbool.h>
#else
typedef enum {
enum {
false = 0,
true = 1
} qboolean;
};
#endif
#endif /* */
COMPILE_TIME_ASSERT(falsehood, ((1 != 1) == false));
COMPILE_TIME_ASSERT(truth, ((1 == 1) == true));
#endif
COMPILE_TIME_ASSERT(qboolean, sizeof(qboolean) == 4);

/*==========================================================================*/
Expand Down

0 comments on commit 597c204

Please sign in to comment.