Bug 708290

Summary: Ghostscript fails to build with C23 standard
Product: Ghostscript Reporter: zdohnal <zdohnal>
Component: Build ProcessAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED DUPLICATE    
Severity: normal CC: alex, chris.liddell
Priority: P2    
Version: 10.04.0   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---

Description zdohnal 2025-02-11 17:15:47 UTC
Hi,

when a compiler/user tries to use the newest C standard - C23, Ghostscript is not able to be built due errors. The initial error is:

```
gcc   -O2 -DNDEBUG -Wall -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings -fno-strict-aliasing -Werror=declaration-after-statement -fno-builtin -fno-common -Werror=return-type -Wno-unused-local-typedefs -DHAVE_STDINT_H=1 -DHAVE_DIRENT_H=1 -DHAVE_SYS_DIR_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_TIMES_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_LIBDL=1 -DGX_COLOR_INDEX_TYPE="unsigned long long" -D__USE_UNIX98=1 -DHAVE_SNPRINTF  -std=c23 -DHAVE_RESTRICT=1 -fno-strict-aliasing   -I./base -o ./obj/aux/genconf ./base/genconf.c     -lm -ldl  -rdynamic -lfontconfig -lfreetype    
In file included from ./base/genconf.c:18:
./base/stdpre.h:348:13: error: two or more data types in declaration specifiers
  348 | typedef int bool;
      |             ^~~~
./base/stdpre.h:348:1: warning: useless type name in empty declaration
  348 | typedef int bool;
      | ^~~~~~~
make: *** [base/unix-aux.mak:71: obj/aux/genconf] Error 1
```

but later there are many incompatible pointer type errors due mixing int and bool data types...


How to reproduce in ghostpdl git repo:

$ ./autogen.sh
$ CFLAGS="${CFLAGS} -std=c23" ./configure --without-x --disable-compile-inits --without-versioned-path
$ make


OS: Fedora 41 (but any OS with compiler with C23 standard will do)
Compiler: gcc-14.2.1-7.fc41.x86_64, but any supporting C23 will do.


This was found during Fedora 42, where GCC 15 defaults to the newest standard. We will switch to gnu17 for now, because the fix is quite complex.

Would you mind looking into it?


Thank you in advance!


Zdenek
Comment 1 Chris Liddell (chrisl) 2025-02-11 17:22:45 UTC
We'll get to it. But it will take a while.
Comment 2 Alex Cherepanov 2025-02-11 19:12:35 UTC

*** This bug has been marked as a duplicate of bug 708160 ***