diff options
author | Corey Farrell <git@cfware.com> | 2018-07-14 13:24:55 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-07-14 13:24:55 -0400 |
commit | 81fe13eeed91d5c973db63d2f662ae766a8832c4 (patch) | |
tree | dfb0fa3fe019c61e00d3aa0e69eaa0617ea4fbbe /configure.ac | |
parent | aed855e6920923898b94a1b922fbace27a34ddf2 (diff) | |
download | jansson-81fe13eeed91d5c973db63d2f662ae766a8832c4.zip jansson-81fe13eeed91d5c973db63d2f662ae766a8832c4.tar.gz jansson-81fe13eeed91d5c973db63d2f662ae766a8832c4.tar.bz2 |
Deal with warnings under gcc 8.
Recent versions of gcc have introduced compiler warnings for string
operations that could be truncated. This caused problems with -Werror.
src/error.c used strncpy to write "..." to a string, but skipped writing
the NUL terminator. Switch this to use memcpy. src/load.c produced
warnings from snprintf writing error strings that could be truncated.
Added code to autotools build to detect `-Wno-format-truncation', add it
to AM_CFLAGS if supported.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 4ab9d3d..ca12b59 100644 --- a/configure.ac +++ b/configure.ac @@ -108,7 +108,14 @@ AC_DEFINE_UNQUOTED([INITIAL_HASHTABLE_ORDER], [$initial_hashtable_order], [Number of buckets new object hashtables contain is 2 raised to this power. E.g. 3 -> 2^3 = 8.]) if test x$GCC = xyes; then - AM_CFLAGS="-Wall -Wextra -Wdeclaration-after-statement" + AC_MSG_CHECKING(for -Wno-format-truncation) + wnoformat_truncation="-Wno-format-truncation" + AS_IF([${CC} -Wno-format-truncation -Werror -S -o /dev/null -xc /dev/null > /dev/null 2>&1], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + wnoformat_truncation=""]) + + AM_CFLAGS="-Wall -Wextra -Wdeclaration-after-statement ${wnoformat_truncation}" fi AC_SUBST([AM_CFLAGS]) |