64 lines
2.1 KiB
Diff
64 lines
2.1 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(-)
|
|
|
|
Index: crispy-doom-crispy-doom-7.0/CMakeLists.txt
|
|
===================================================================
|
|
--- crispy-doom-crispy-doom-7.0.orig/CMakeLists.txt
|
|
+++ crispy-doom-crispy-doom-7.0/CMakeLists.txt
|
|
@@ -3,6 +3,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_S
|
|
cmake_minimum_required(VERSION 3.7.2)
|
|
project("Crispy Doom" VERSION 7.0.0 LANGUAGES C)
|
|
|
|
+set(CMAKE_C_STANDARD 99)
|
|
+
|
|
# Autotools variables
|
|
set(top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
|
|
set(top_builddir ${CMAKE_CURRENT_BINARY_DIR})
|
|
Index: crispy-doom-crispy-doom-7.0/configure.ac
|
|
===================================================================
|
|
--- crispy-doom-crispy-doom-7.0.orig/configure.ac
|
|
+++ crispy-doom-crispy-doom-7.0/configure.ac
|
|
@@ -16,7 +16,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)
|
|
|
|
Index: crispy-doom-crispy-doom-7.0/src/doomtype.h
|
|
===================================================================
|
|
--- crispy-doom-crispy-doom-7.0.orig/src/doomtype.h
|
|
+++ crispy-doom-crispy-doom-7.0/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
|
|
|