From 3618c26dc1ee8b33fbb1e24989cf9438d7212e0a Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 11 Jun 2011 13:20:13 +0000 Subject: [PATCH] updated q_stdinc.h from uhexen2. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@459 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/q_stdinc.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/quakespasm/Quake/q_stdinc.h b/quakespasm/Quake/q_stdinc.h index 3176cf13..f0bffe9f 100644 --- a/quakespasm/Quake/q_stdinc.h +++ b/quakespasm/Quake/q_stdinc.h @@ -2,9 +2,12 @@ q_stdinc.h includes the minimum necessary stdc headers, defines common and / or missing types. + NOTE: for net stuff use net_sys.h, + for byte order use q_endian.h, + for math stuff use mathlib.h. Copyright (C) 1996-1997 Id Software, Inc. - Copyright (C) 2007-2008 O.Sezer + Copyright (C) 2007-2011 O.Sezer This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -42,6 +45,8 @@ sizeof (float) == 4 sizeof (long) == 4 / 8 sizeof (pointer *) == 4 / 8 + For this, we need stdint.h (or inttypes.h) + FIXME: On some platforms, only inttypes.h is available. FIXME: Properly replace certain short and int usage with int16_t and int32_t. */ @@ -57,7 +62,7 @@ #include #include #include -#if !(defined(_WIN32) || defined(_WIN64)) +#if !defined(_WIN32) #include /* strcasecmp and strncasecmp */ #endif /* ! PLATFORM_WINDOWS */ @@ -117,17 +122,21 @@ typedef unsigned char byte; #undef true #undef false #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 ... */ +/* 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. */ typedef int qboolean; +COMPILE_TIME_ASSERT(falsehood, (0 == false)); +COMPILE_TIME_ASSERT(truth, (1 == true)); #else typedef enum { false = 0, true = 1 } qboolean; +COMPILE_TIME_ASSERT(falsehood, ((1 != 1) == false)); +COMPILE_TIME_ASSERT(truth, ((1 == 1) == true)); #endif - +COMPILE_TIME_ASSERT(qboolean, sizeof(qboolean) == 4); /*==========================================================================*/ @@ -151,12 +160,10 @@ typedef int ssize_t; #endif /* _MSC_VER */ /* compatibility with M$ types */ -#if !(defined(_WIN32) || defined(_WIN64)) - +#if !defined(_WIN32) #define PASCAL #define FAR #define APIENTRY - #endif /* ! WINDOWS */ #if !defined(__GNUC__)