Re: [tcpdump-workers] -W options to gcc
About warnings and gcc specifics, II tried the gcc option -pedantic and I got (among others): [...] ./print-olsr.c:197: warning: ISO C90 does not support the '%lf' gnu_printf format [...] ./print-rx.c:856: warning: ISO C90 does not support the '%T' gnu_strftime format [...] ./tcpdump.c:1217:27: warning: C++ style comments are not allowed in ISO C90 ./tcpdump.c:1217:27: warning: (this will be reported only once per input file) [...] Perhaps portability problems ... Francois-Xavier - Original Message - On Mar 28, 2013, at 4:41 PM, Michael Richardson m...@sandelman.ca wrote: Guy == Guy Harris g...@alum.mit.edu writes: Guy Wireshark's configure script checks whether the GCC shell Guy variable is yes or the CC shell variable is clang and, if Guy true, sets a flag saying this compiler supports -W options. Cooll.. can we copy and paste :-) Wireshark's configuration scripts are GPLed, along with the rest of Wireshark, so, in principle, that might be a problem. I didn't originally write that macro, so I can't just relicense it. I don't know whether anybody'd care, however. (I've moved stuff of mine between Wireshark and tcpdump/libpcap configure scripts in the past.) ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
[tcpdump-workers] -W options to gcc
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. 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. fxlb suggested: -Wunused -Wunused-parameter -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works| network architect [ ] m...@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
Re: [tcpdump-workers] -W options to gcc
Michael Richardson m...@sandelman.ca wrote: 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. fxlb suggested: -Wunused -Wunused-parameter I compile using MingW (gcc 4.7.2) and normally I use -Wall -W. But this gives tons of warnings. Hence I use these to supress most of them: -Wno-unused-but-set-variable -Wno-unused-function -Wno-strict-aliasing This results in only these warnings: missing/inet_ntop.c: In function 'inet_ntop': missing/inet_ntop.c:146:44: warning: 'best.len' may be used uninitialized in this function [-Wmaybe-uninitialized] missing/inet_ntop.c:117:5: note: 'best.len' was declared here Must be one of the oldest file in tcpdump. From 2005. --gv ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
Gisle == Gisle Vanem gva...@broadpark.no writes: Gisle I compile using MingW (gcc 4.7.2) and normally I use Gisle -Wall -W. sure, I'd like to get to -Wall -Werror at some point, but for the moment, I want to know how to include -Wgcc-things when we are using gcc, and omit when we aren't. -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works| network architect [ ] m...@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
Re: [tcpdump-workers] -W options to gcc
28.03.2013, 17:55, Michael Richardson m...@sandelman.ca: Gisle == Gisle Vanem gva...@broadpark.no writes: Gisle I compile using MingW (gcc 4.7.2) and normally I use Gisle -Wall -W. sure, I'd like to get to -Wall -Werror at some point, but for the moment, I want to know how to include -Wgcc-things when we are using gcc, and omit when we aren't. This is from autoconf documentation: Macro: AC_PROG_CC ([compiler-search-list]) [...] If using the GNU C compiler, set shell variable GCC to ‘yes’. -- Denis Ovsienko ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
Gisle == Gisle Vanem gva...@broadpark.no writes: Gisle I compile using MingW (gcc 4.7.2) and normally I use Gisle -Wall -W. sure, I'd like to get to -Wall -Werror at some point, but for the moment, I want to know how to include -Wgcc-things when we are using gcc, and omit when we aren't. You probably want to include (some of) them when using some other compilers (eg clang) that are likely to support the same options. There are problems with -Werror for release software in that different versions of gcc will detect different errors. Particularly if some aggressive function inlining is done. David ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
On Mar 28, 2013, at 5:37 AM, Michael Richardson m...@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 [ ] m...@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
Re: [tcpdump-workers] -W options to gcc
Guy == Guy Harris g...@alum.mit.edu writes: Guy Wireshark's configure script checks whether the GCC shell Guy variable is yes or the CC shell variable is clang and, if Guy true, sets a flag saying this compiler supports -W options. Cooll.. can we copy and paste :-) Guy There's no C++ code in libpcap or tcpdump, so the second Guy argument isn't necessary. true... but it won't hurt, and why let the code diverge? -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works| network architect [ ] m...@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
Re: [tcpdump-workers] -W options to gcc
On Mar 28, 2013, at 4:41 PM, Michael Richardson m...@sandelman.ca wrote: Guy == Guy Harris g...@alum.mit.edu writes: Guy Wireshark's configure script checks whether the GCC shell Guy variable is yes or the CC shell variable is clang and, if Guy true, sets a flag saying this compiler supports -W options. Cooll.. can we copy and paste :-) Wireshark's configuration scripts are GPLed, along with the rest of Wireshark, so, in principle, that might be a problem. I didn't originally write that macro, so I can't just relicense it. I don't know whether anybody'd care, however. (I've moved stuff of mine between Wireshark and tcpdump/libpcap configure scripts in the past.) ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers