Bug 703948

Summary: GhostPDL 9.54.0 does not compile with GCC 4.2 on PowerPC MacOSX 10.5.8, Leopard, because "#pragma GCC diagnostic not allowed inside functions"
Product: GhostPDL Reporter: Peter Dyballa <Peter_Dyballa>
Component: Graphics LibraryAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED FIXED    
Severity: normal CC: emmiller
Priority: P4    
Version: 9.54.0   
Hardware: Macintosh   
OS: MacOS X   
Customer: Word Size: ---
Attachments: Proposed fix for GCC 4.2 and earlier

Description Peter Dyballa 2021-06-17 09:52:32 UTC
make[2]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_print_ghostscript/ghostscript/work/ghostpdl-9.54.0'
/usr/bin/gcc-4.2 -std=gnu99   -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 -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 -D"strnlen(a,b)=strlen(a)" -pipe -Os -arch ppc -DHAVE_RESTRICT=1 -fno-strict-aliasing -DHAVE_POPEN_PROTO=1  -I./base -o ./soobj/aux/genconf ./base/genconf.c  -lm -ldl  -liconv -L/opt/local/lib -lidn -lpaper -L/opt/local/lib -ltiff  -L/opt/local/lib -lfontconfig -lfreetype -lfreetype -L/opt/local/lib -lopenjp2  -lz
./soobj/aux/genarch ./soobj/arch.h ./base/../arch/osx-x86-x86_64-ppc-gcc.h
/usr/bin/gcc-4.2 -std=gnu99  -DHAVE_MKSTEMP  -DHAVE_FSEEKO  -DHAVE_FONTCONFIG -DHAVE_LIBIDN -DHAVE_SETLOCALE   -DHAVE_BSWAP32  -DHAVE_STRERROR -DHAVE_ISNAN -DHAVE_ISINF  -DHAVE_PREAD_PWRITE=1 -DGS_RECURSIVE_MUTEXATTR=PTHREAD_MUTEX_RECURSIVE -O2 -DNDEBUG -fPIC           -isystem/opt/local/include  -Wall -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings -fno-strict-aliasing -Werror=declaration-after-statement -fno-builtin -fno-common -Werror=return-type -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 -D"strnlen(a,b)=strlen(a)" -pipe -Os -arch ppc -DHAVE_RESTRICT=1 -DUSE_LIBICONV_GNU  -DUSE_LIBPAPER  -fno-strict-aliasing -DHAVE_POPEN_PROTO=1   -I./soobj -I./base -I./devices  -DWHICH_CMS="lcms2" -o ./soobj/gp_getnv.o -c ./base/gp_getnv.c
In file included from ./base/srdline.h:23,
                 from ./base/gp.h:41,
                 from ./base/gp_getnv.c:22:
./base/scommon.h: In function ‘stream_cursor_read_init’:
./base/scommon.h:122: error: #pragma GCC diagnostic not allowed inside functions
./base/scommon.h:123: error: #pragma GCC diagnostic not allowed inside functions
./base/scommon.h:129: error: #pragma GCC diagnostic not allowed inside functions
./base/scommon.h: In function ‘stream_cursor_write_init’:
./base/scommon.h:137: error: #pragma GCC diagnostic not allowed inside functions
./base/scommon.h:138: error: #pragma GCC diagnostic not allowed inside functions
./base/scommon.h:144: error: #pragma GCC diagnostic not allowed inside functions
make[2]: *** [soobj/gp_getnv.o] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_print_ghostscript/ghostscript/work/ghostpdl-9.54.0'
make[1]: *** [so-only-subtarget] Error 2
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_print_ghostscript/ghostscript/work/ghostpdl-9.54.0'
make: *** [so] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_print_ghostscript/ghostscript/work/ghostpdl-9.54.0'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_print_ghostscript/ghostscript/work/ghostpdl-9.54.0" && /usr/bin/make -j1 -w so 
Exit code: 2


Removing the #pragmas allowed GhostPDL to build with GCC 4.2. Using GCC7 (7.5.0) no problem appears.
Comment 1 Evan Miller 2021-07-19 16:53:23 UTC
Created attachment 21241 [details]
Proposed fix for GCC 4.2 and earlier

Patch to move the pragmas outside the function bodies to make GCC 4.2 happy.
Comment 2 Chris Liddell (chrisl) 2021-08-19 07:31:41 UTC
Patch applied - thank you!

https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=a9ce865035e7