tcpdump mailing list archives
Re: -W options to gcc
From: Guy Harris <guy () alum mit edu>
Date: Thu, 28 Mar 2013 11:54:28 -0700
On Mar 28, 2013, at 5:37 AM, Michael Richardson <mcr () sandelman ca> wrote:
While I'll bet that 95% of *nix systems that compile tcpdump regularly are using gcc, I know that there remain other compilers in use.
...at least some of which may support -W options, and at least one of which (clang) supports most if not all of the same -W options that GCC does.
If one wants to add -W options to the standard build, I'm wondering what the right autoconf magic is to enable such a thing.
Wireshark's configure script checks whether the GCC shell variable is "yes" or the CC shell variable is "clang" and, if true, sets a flag saying "this compiler supports -W options". It then has a macro that takes, as arguments, a list of one or more flags to add; an optional indication of whether the flags are for C, C++, or both; an optional program to compile with the flag and with -Werror - if the compile fails, the option is not added (this handles some flags that issue incorrect or non-useful warnings with some compiler versions); if the third argument is supplied, a fourth argument which is a message describing what the test program is checking and, if the compiler supports -W options, doesn't fail if you pass it the -W option in question when compiling a trivial program (this tests whether the option is supported at all), and, if the test program is supplied, it compiles OK, it adds the flags to CFLAGS, CXXFLAGS, or both. (If the compiler is clang, you also have to pass -Werror=unknown-warning-option, so the compiler doesn't just print out a warning message and compile anyway; that way, we don't include a pile of unsupported -W flags and get a pile of warnings for every compilation.) There's no C++ code in libpcap or tcpdump, so the second argument isn't necessary. The third and fourth arguments are used to: avoid using -Wshadow if, when set, the compiler bogusly complains about variables in function and function pointer declarations shadowing other variables (which some versions of GCC do); avoid using -Wlogical-op if strchr() is given a constant string; so unless we plan to use those -W flags, we don't need them - no other tricky -W flags were found.
fxlb suggested: "-Wunused -Wunused-parameter" -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works | network architect [ ] mcr () sandelman ca http://www.sandelman.ca/ | ruby on rails [ _______________________________________________ tcpdump-workers mailing list tcpdump-workers () lists tcpdump org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
_______________________________________________ tcpdump-workers mailing list tcpdump-workers () lists tcpdump org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Current thread:
- -W options to gcc Michael Richardson (Mar 28)
- Re: -W options to gcc Gisle Vanem (Mar 28)
- Re: -W options to gcc Michael Richardson (Mar 28)
- Re: -W options to gcc Denis Ovsienko (Mar 28)
- Re: -W options to gcc David Laight (Mar 28)
- Re: -W options to gcc Michael Richardson (Mar 28)
- Re: -W options to gcc Guy Harris (Mar 28)
- Re: -W options to gcc Michael Richardson (Mar 28)
- Re: -W options to gcc Guy Harris (Mar 28)
- Re: -W options to gcc Michael Richardson (Mar 28)
- Re: -W options to gcc Gisle Vanem (Mar 28)