On Mon, 10 Feb 2014 17:01:57 -0500, Dale Visser <dale.vis...@gmail.com> wrote:
> I've created a new patch (attached) incorporating your suggestions. See my > comments inline below. Excellent! > Done, with the wording you suggested. On my system (gcc version is 4.8.1), I > tested the gcc oddity you mentioned and found that it only applied to flags > of the form -Wno-*. E.g., -Wnosuchoption and -Wjunk would still not be added, > but -Wno-way would be added and harmlessly ignored. Okay, much better. > > ./doc/autoconf.texi:23579: warning: `(' follows defined name > > `AC_APPEND_FLAG_IFVALID' instead of whitespace. > > Can you fix the documentation to remove those warnings? > Done. For some reason, those warning never showed for me. How fitting... :-) I tried it out. Now it works for me, good. > Thank you for your helpful comments. Let me know what you think of the latest. Thanks. I ran a test case (using gcc as the C compiler), here's what running my configure now looks like: ... checking CFLAGS for maximum warnings... -Wall checking for style of include used by make... GNU checking dependency style of gcc -std=gnu11... gcc3 checking if -Wno-such-option can be added to CFLAGS... yes ... That looks perfect, it's certainly clear what's going on. When I run "make" on the resulting Makefile (after "touch"ing my .c file), I get the following output: gcc -std=gnu11 -DHAVE_CONFIG_H -I. -Wall -Wno-such-option -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c hello.c:3:22: warning: "/*" within comment [-Wcomment] cc1: warning: unrecognized command line option "-Wno-such-option" [enabled by default] mv -f .deps/hello.Tpo .deps/hello.Po The first warning is exactly what I expect ("/*" within comment), excellent. I even added this to configure.ac: AC_APPEND_FLAG_IFVALID([-Wno-comment]) and as expected it turned off "-Wcomment". This makes it really easy to turn on & off warning flags, while still making it portable. Excellent. I'm a little annoyed by the second warning, though, the one that says: cc1: warning: unrecognized command line option "-Wno-such-option" [enabled by default] I presume this happens because there's no error return given an unrecognized command line option. That's not a *killer*, but that would be annoying since it'd repeat in every compile. Is there a way your "_IFVALID" macro could detect this case (e.g., by compiling with and without, and noticing if the name of the option showed up in a line only output by the "it's on" case?) Or maybe is there some other way to detect that adding a flag would not really be valid? I admit that this can only occur if (1) the compiler is gcc and (2) you use a flag of the form -Wno-* where "*" isn't supported, so maybe this is a case not worth creating a complex solution. But if there's an easy refinement it'd be nice to have. --- David A. Wheeler