diff options
author | Guy Harris <gharris@sonic.net> | 2021-07-25 02:17:19 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-07-25 02:17:19 -0700 |
commit | 8336c296aff1e7cd0172704ae0e11dd2dc275383 (patch) | |
tree | 80d8a392578d955fdba37570b46721ee4bfb6d04 /aclocal.m4 | |
parent | f3b6dcabe6b6f88a449e887af080bf1d76ddc0c4 (diff) |
configure: AC_TRY_COMPILE() generates a return; don't add one.
If we pass [return 0] to AC_TRY_COMPILE(), the test program it compiles
has two "return 0;" statements in a row, and one of the -W flags we
tests reports a warning for that.
We were testing whether a -W flag is supported by checking the standard
error of the compiler to see if *any* error/warning messages are
generated, and treating the flag as unsupported if any are, that meant
that -Wunreachable-code-return was be treated as unsupported even though
it *is* supported.
This should fix that. (That flag isn't currently used here, but it is
used for tcpdump, and we want to make this change and the previous
change in tcpdump as well. I'm so glad autoconf makes this all so
difficult to do correctly....)
Diffstat (limited to 'aclocal.m4')
-rw-r--r-- | aclocal.m4 | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -260,9 +260,41 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT, # save_ac_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes + # + # XXX - with autoconf 2.69, at least, the test program that this + # tries to compile is: + # + # int + # main () + # { + # + # ; + # return 0; + # } + # + # Hopefully, neither the empty statement nor the old-style + # definition of main() will, with any command-line flag + # whatsoever with which we test, on any compiler we test, + # will produce any warnings whatsoever; if it does, the + # command-line flag with which we test will be treated as + # not being supported even if it is supported. + # + # Thanks, autoconf, for making it *so* difficult to generate + # an absolute minimum valid C-with-everything-prototyped + # program as a test program, such as + # + # int main(void) { return 0; }. + # + # (with autoconf 2.69, at least, using AC_LANG_CONFTEST() with + # AC_LANG_SOURCE([<code>]) produces the same function boilerplate + # as AC_LANG_PROGRAM([],[<code>]), complete with the main() + # function wrapper, the extra semicolon, and the return 0;, + # raising the question of "why, then, do both AC_LANG_SOURCE() + # and AC_LANG_PROGRAM() exist?"). + # AC_TRY_COMPILE( [], - [return 0], + [], [ AC_MSG_RESULT([yes]) can_add_to_cflags=yes |