Skip to content

Commit

Permalink
Add garbage to files for ISO-compliant compilers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhymeswithmogul committed Oct 27, 2024
1 parent 9880993 commit b325561
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
17 changes: 9 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -194,4 +195,4 @@ OPTIONS:
APRS-IS support: $enable_aprs_is
Debugging output: $enable_debug
###########################
])
])
6 changes: 6 additions & 0 deletions src/aprs-is.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

6 changes: 6 additions & 0 deletions src/c99math.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit b325561

Please sign in to comment.