1From c595086bfe206776676e290df98cd09e91210e27 Mon Sep 17 00:00:00 2001
2From: Alex Cherepanov <alex@coscript.biz>
3Date: Thu, 3 Apr 2025 17:19:41 +0100
4Subject: [PATCH] Bug 708160: Fix compatibility with C23 compilers
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9* fixes:
10  http://errors.yoctoproject.org/Errors/Details/853021/
11
12In file included from ./base/genconf.c:18:
13./base/stdpre.h:348:13: error: ‘bool’ cannot be defined via ‘typedef’
14  348 | typedef int bool;
15      |             ^~~~
16./base/stdpre.h:348:13: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
17./base/stdpre.h:348:1: warning: useless type name in empty declaration
18  348 | typedef int bool;
19      | ^~~~~~~
20
21Upstream-Status: Backport [Partial backport of https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/commit/base/stdpre.h?id=ae940946473ceb8c5353bc6e7f04673c6e60502d]
22
23Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
24---
25 base/stdpre.h | 6 ++++--
26 1 file changed, 4 insertions(+), 2 deletions(-)
27
28diff --git a/base/stdpre.h b/base/stdpre.h
29index dda30b6..2f9c84e 100644
30--- a/base/stdpre.h
31+++ b/base/stdpre.h
32@@ -1,4 +1,4 @@
33-/* Copyright (C) 2001-2023 Artifex Software, Inc.
34+/* Copyright (C) 2001-2025 Artifex Software, Inc.
35    All Rights Reserved.
36
37    This software is provided AS-IS with no warranty, either express or
38@@ -341,7 +341,9 @@ typedef signed char schar;
39  * and the MetroWerks C++ compiler insists that bool be equivalent to
40  * unsigned char.
41  */
42-#ifndef __cplusplus
43+
44+/* C23 has bool as a builtin type. */
45+#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L)
46 #ifdef __BEOS__
47 typedef unsigned char bool;
48 #else
49diff --git a/base/gp.h b/base/gp.h
50index ad5bb61..cf2c9cf 100644
51--- a/base/gp.h
52+++ b/base/gp.h
53@@ -1,4 +1,4 @@
54-/* Copyright (C) 2001-2023 Artifex Software, Inc.
55+/* Copyright (C) 2001-2025 Artifex Software, Inc.
56    All Rights Reserved.
57
58    This software is provided AS-IS with no warranty, either express or
59@@ -646,7 +646,7 @@ int gp_fseek_impl(FILE *strm, gs_offset_t offset, int origin);
60 /* Create a second open gp_file on the basis of a given one */
61 FILE *gp_fdup_impl(FILE *f, const char *mode);
62
63-int gp_fseekable_impl(FILE *f);
64+bool gp_fseekable_impl(FILE *f);
65
66 /* Force given file into binary mode (no eol translations, etc) */
67 /* if 2nd param true, text mode if 2nd param false */
68