mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Redefine boolean for C++ compatibility
This commit is contained in:
parent
5139d1276b
commit
7423b05f46
4 changed files with 37 additions and 33 deletions
|
|
@ -370,6 +370,7 @@ endif()
|
||||||
|
|
||||||
add_subdirectory(sdl)
|
add_subdirectory(sdl)
|
||||||
add_subdirectory(objects)
|
add_subdirectory(objects)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|
||||||
# strip debug symbols into separate file when using gcc.
|
# strip debug symbols into separate file when using gcc.
|
||||||
# to be consistent with Makefile, don't generate for OS X.
|
# to be consistent with Makefile, don't generate for OS X.
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@
|
||||||
#ifndef __DOOMTYPE__
|
#ifndef __DOOMTYPE__
|
||||||
#define __DOOMTYPE__
|
#define __DOOMTYPE__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//#define WIN32_LEAN_AND_MEAN
|
//#define WIN32_LEAN_AND_MEAN
|
||||||
#define RPC_NO_WINDOWS_H
|
#define RPC_NO_WINDOWS_H
|
||||||
|
|
@ -107,24 +111,6 @@ typedef long ssize_t;
|
||||||
char *strcasestr(const char *in, const char *what);
|
char *strcasestr(const char *in, const char *what);
|
||||||
#define stristr strcasestr
|
#define stristr strcasestr
|
||||||
|
|
||||||
#if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap
|
|
||||||
#define true 1
|
|
||||||
#define false 0
|
|
||||||
#define min(x,y) (((x)<(y)) ? (x) : (y))
|
|
||||||
#define max(x,y) (((x)>(y)) ? (x) : (y))
|
|
||||||
|
|
||||||
#ifdef macintosh
|
|
||||||
#define stricmp strcmp
|
|
||||||
#define strnicmp strncmp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define boolean INT32
|
|
||||||
|
|
||||||
#ifndef O_BINARY
|
|
||||||
#define O_BINARY 0
|
|
||||||
#endif
|
|
||||||
#endif //macintosh
|
|
||||||
|
|
||||||
#if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__)
|
#if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__)
|
||||||
#define HAVE_DOSSTR_FUNCS
|
#define HAVE_DOSSTR_FUNCS
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -151,22 +137,24 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||||
|
|
||||||
/* Boolean type definition */
|
/* Boolean type definition */
|
||||||
|
|
||||||
// \note __BYTEBOOL__ used to be set above if "macintosh" was defined,
|
// Note: C++ bool and C99/C11 _Bool are NOT compatible.
|
||||||
// if macintosh's version of boolean type isn't needed anymore, then isn't this macro pointless now?
|
// Historically, boolean was win32 BOOL on Windows. For equivalence, it's now
|
||||||
#ifndef __BYTEBOOL__
|
// int32_t. "true" and "false" are only declared for C code; in C++, conversion
|
||||||
#define __BYTEBOOL__
|
// between "bool" and "int32_t" takes over.
|
||||||
|
#ifndef _WIN32
|
||||||
|
typedef int32_t boolean;
|
||||||
|
#else
|
||||||
|
#define BOOL boolean
|
||||||
|
#endif
|
||||||
|
|
||||||
//faB: clean that up !!
|
#ifndef __cplusplus
|
||||||
#if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward
|
#ifndef _WIN32
|
||||||
#include "stdbool.h"
|
enum {false = 0, true = 1};
|
||||||
#elif defined (_WIN32)
|
#else
|
||||||
#define false FALSE // use windows types
|
#define false FALSE
|
||||||
#define true TRUE
|
#define true TRUE
|
||||||
#define boolean BOOL
|
#endif
|
||||||
#else
|
#endif
|
||||||
typedef enum {false, true} boolean;
|
|
||||||
#endif
|
|
||||||
#endif // __BYTEBOOL__
|
|
||||||
|
|
||||||
/* 7.18.2.1 Limits of exact-width integer types */
|
/* 7.18.2.1 Limits of exact-width integer types */
|
||||||
|
|
||||||
|
|
@ -408,4 +396,8 @@ typedef UINT64 precise_t;
|
||||||
|
|
||||||
#include "typedef.h"
|
#include "typedef.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //__DOOMTYPE__
|
#endif //__DOOMTYPE__
|
||||||
|
|
|
||||||
3
src/tests/CMakeLists.txt
Normal file
3
src/tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
target_sources(srb2tests PRIVATE
|
||||||
|
boolcompat.cpp
|
||||||
|
)
|
||||||
8
src/tests/boolcompat.cpp
Normal file
8
src/tests/boolcompat.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "../doomtype.h"
|
||||||
|
|
||||||
|
TEST_CASE("C++ bool is convertible to doomtype.h boolean") {
|
||||||
|
REQUIRE(static_cast<boolean>(true) == 1);
|
||||||
|
REQUIRE(static_cast<boolean>(false) == 0);
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue