From 94d37020265c5946f950ec33242d465f09244fb2 Mon Sep 17 00:00:00 2001 From: sezero Date: Mon, 31 May 2010 12:10:25 +0000 Subject: [PATCH] common.h: tweak the qboolean and NULL definitions for __cplusplus. from uhexen2. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@176 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/common.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Quake/common.h b/Quake/common.h index 0d3d9079..83a30f0d 100644 --- a/Quake/common.h +++ b/Quake/common.h @@ -31,8 +31,17 @@ typedef unsigned char byte; #undef true #undef false - -typedef enum {false, true} qboolean; +#if defined(__cplusplus) +/* do NOT use the bool of C++ because some structures have boolean and they + * expect it to be 4 bytes long. as a hack, typedef it as int. */ +/* DO HOPE that the compiler built-ins for true and false are 1 and 0 ... */ +typedef int qboolean; +#else +typedef enum { + false = 0, + true = 1 +} qboolean; +#endif //============================================================================ @@ -73,8 +82,12 @@ void InsertLinkAfter (link_t *l, link_t *after); //============================================================================ #ifndef NULL +#if defined(__cplusplus) +#define NULL 0 +#else #define NULL ((void *)0) #endif +#endif #define Q_MAXCHAR ((char)0x7f) #define Q_MAXSHORT ((short)0x7fff)