resurrecting-open-source-projects / scrot

SCReenshOT - command line screen capture utility
Other
512 stars 51 forks source link

1.8.1 not compiling in C99 mode on CentOS 7 #225

Closed guijan closed 1 year ago

guijan commented 1 year ago

pkgsrc's automated testing says 1.8.1 fails to build on CentOS 7: https://us-central.manta.mnx.io/pkgsrc/public/reports/Linux/el7/trunk/x86_64/20230315.2239//scrot-1.8.1/build.log https://bulktracker.appspot.com/pkg/ag1zfmJ1bGt0cmFja2VyciILEgVidWlsZBiAgICD5MX3CwwLEgNwa2cYgICAvfWc1AoM

The error message is:

scrot.c:346:13: error: 'for' loop initial declarations are only allowed in C99 mode

For whatever reason it's compiling in C89 mode. Something wrong with our configure.ac?

N-R-K commented 1 year ago

It seems like their cc is running at C89 by default. We can add -std=c99 to our default CFLAGS, but -std is not guaranteed to be portable.

We could also call c99 instead of default cc but I don't think that's a good idea either since c99 on macos is weird.

guijan commented 1 year ago

Starting with autoconf 2.70, AC_PROG_CC determines the C compiler and tries to use C11, falling back to C99 and then C89 if it fails, and AC_PROG_CC_STDC is obsolete: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/C-Compiler.html (CTRL+F AC_PROG_CC) https://lwn.net/Articles/839395/ (CTRL+F AC_PROG_CC_STDC). In autoconf 2.69 and earlier versions, AC_PROG_CC merely determines the C compiler, and AC_PROG_CC_STDC tries to make the compiler use C99 if it's available, C89 otherwise: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/C-Compiler.html

So this bug was introduced by https://github.com/resurrecting-open-source-projects/scrot/commit/2c36e31d7c6ee3859d56e6e6e547492b813bffc3 Scrot used AM_PROG_CC_STDC back then which appears to do the same thing as AC_PROG_CC_STDC except it's part of autoconf-archive.

The fix should be to call AC_PROG_CC_STDC after AC_PROG_CC if autoconf's version is <= 2.69

N-R-K commented 1 year ago

The fix should be to call AC_PROG_CC_STDC after AC_PROG_CC if autoconf's version is <= 2.69

Sounds OK, probably also want to put a comment in there, since I assume this is something we'd want to remove at some later point in the future once distros have upgraded.