forked from jengelh/chocolate-doom
If the fix looks OK, please also forward it to Factory soonish so that it is ready when we switch the compiler.
64 lines
1.8 KiB
Diff
64 lines
1.8 KiB
Diff
From 57e0cdf606bcf9a518f2cad99831133396c015fa Mon Sep 17 00:00:00 2001
|
|
From: Fabian Greffrath <fabian@greffrath.com>
|
|
Date: Mon, 20 Jan 2025 17:22:48 +0100
|
|
Subject: [PATCH] declare code as C99 compliant, include stdbool.h
|
|
unconditionally (#1723)
|
|
|
|
* declare code as C99 compliant, include stdbool.h unconditionally
|
|
|
|
* add a comment why `boolean` must be an `int` type
|
|
---
|
|
CMakeLists.txt | 2 ++
|
|
configure.ac | 2 +-
|
|
src/doomtype.h | 7 +++++--
|
|
3 files changed, 8 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 5a058d7706..a7456650c4 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -3,6 +3,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
cmake_minimum_required(VERSION 3.7.2)
|
|
project("Chocolate Doom" VERSION 3.1.0 LANGUAGES C)
|
|
|
|
+set(CMAKE_C_STANDARD 99)
|
|
+
|
|
# Autotools variables
|
|
set(top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
|
|
set(top_builddir ${CMAKE_CURRENT_BINARY_DIR})
|
|
diff --git a/configure.ac b/configure.ac
|
|
index 7bf04169fb..fbc1dd51db 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -39,7 +39,7 @@ AC_CANONICAL_HOST
|
|
orig_CFLAGS="$CFLAGS"
|
|
|
|
AM_PROG_AR
|
|
-AC_PROG_CC
|
|
+AC_PROG_CC_C99
|
|
AC_PROG_RANLIB
|
|
AC_CHECK_PROG(HAVE_PYTHON, python3, true, false)
|
|
|
|
diff --git a/src/doomtype.h b/src/doomtype.h
|
|
index 9947a070b5..d90cfec970 100644
|
|
--- a/src/doomtype.h
|
|
+++ b/src/doomtype.h
|
|
@@ -99,12 +99,15 @@
|
|
// standard and defined to include stdint.h, so include this.
|
|
|
|
#include <inttypes.h>
|
|
+#include <stdbool.h>
|
|
|
|
#if defined(__cplusplus) || defined(__bool_true_false_are_defined)
|
|
|
|
-// Use builtin bool type with C++.
|
|
+// The C++/C99 bool type (or _Bool that is) can only have two values:
|
|
+// 0 or 1. However, the Doom source code assumes any non-zero value
|
|
+// to evaluate to true, so we have to use an int type here.
|
|
|
|
-typedef bool boolean;
|
|
+typedef int boolean;
|
|
|
|
#else
|
|
|