From b32556126dd16b388ebf275135cbb5563f66cd30 Mon Sep 17 00:00:00 2001 From: Colin Cogle Date: Sun, 27 Oct 2024 18:01:44 -0400 Subject: [PATCH] Add garbage to files for ISO-compliant compilers. This commit adds a single statement to aprs-is.c and c99math.c that will allow compilation on ISO-compliant compilers, such as GCC with the `-pedantic` or `-pedantic-errors` flags. Under a couple certain conditions -- specifically, when compiling for non-DOS platforms or with APRS-IS disabled -- two source files would wind up blank after preprocessing, which is a violation of the ISO C specifications. This commit adds a single typedef statement to the aforementioned C source files that does nothing to affect program flow but will make even the strictest compilers happy. In the spirit of writing good and portable code (as much as the GNU extensions will allow), I've also added `-pedantic-errors` into the configure.ac script, and by extension, into our Makefile. This will force future maintainers to write high-quality code. --- configure.ac | 17 +++++++++-------- src/aprs-is.c | 6 ++++++ src/c99math.c | 6 ++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 5c10761..bd10f0f 100644 --- a/configure.ac +++ b/configure.ac @@ -38,13 +38,14 @@ AC_TYPE_SIZE_T AC_TYPE_UINT16_T dnl C compiler flags: -dnl -std=gnu99 Compile C99, with GNU extensions (for getaddrinfo, -dnl gai_strerror, freeaddrinfo, struct addrinfo) -dnl -Wall Complain heavily. -dnl -Wextra Complain very heavily. -dnl -Werror Make all warnings errors. -dnl -O2 Optimize (unless we're debugging) -AM_CFLAGS="-std=gnu99 -Wall -Wextra -Werror -O2" +dnl -O2 Optimize (unless we're debugging) +dnl -std=gnu99 Compile C99, with GNU extensions (for getaddrinfo, +dnl gai_strerror, freeaddrinfo, struct addrinfo) +dnl -Wall Complain heavily. +dnl -Wextra Complain very heavily. +dnl -Werror Make all warnings errors. +dnl -pedantic-errors Make sure we're writing compliant C code. +AM_CFLAGS="-O2 -std=gnu99 -Wall -Wextra -Werror -pedantic-errors" AM_LDFLAGS="-lm" AC_SUBST([AM_CFLAGS]) AC_SUBST([AM_LDFLAGS]) @@ -194,4 +195,4 @@ OPTIONS: APRS-IS support: $enable_aprs_is Debugging output: $enable_debug ########################### -]) \ No newline at end of file +]) diff --git a/src/aprs-is.c b/src/aprs-is.c index e8c6952..df88cd5 100755 --- a/src/aprs-is.c +++ b/src/aprs-is.c @@ -214,3 +214,9 @@ sendPacket (const char* const restrict server, } #endif /* HAVE_APRSIS_SUPPORT */ + +/* The following line does nothing. It is present so that ISO-compliant + compilers will not complain about this file being empty (which they + will if we are not compiling with APRS-IS support. */ +typedef int make_iso_compilers_happy; + diff --git a/src/c99math.c b/src/c99math.c index 36a787e..af27d15 100644 --- a/src/c99math.c +++ b/src/c99math.c @@ -84,4 +84,10 @@ round (const double x) #endif /* round */ #endif /* _DOS */ + +/* The following line does nothing. It is present so that ISO-compliant + compilers will not complain about this file being empty (which they + will if _DOS is not defined at compile time. */ +typedef int make_iso_compilers_happy; + #endif /* _APRSWX_C99MATH_H */