Details
Description
marca@SCML-MarcA:~/src/trafficserver-3.0.2$ system_profiler -detailLevel mini | grep 'System Version' System Version: Mac OS X 10.6.8 (10K549) marca@SCML-MarcA:~/src/trafficserver-3.0.2$ ./configure CFLAGS=-w ... checking style of gethostbyname_r routine... glibc2 checking 3rd argument to the gethostbyname_r routines... hostent_data configure: Build using CC=gcc configure: Build using CXX=g++ configure: Build using CPP=gcc -E configure: Build using CFLAGS=-w -g -pipe -Wall -Werror -O3 -feliminate-unused-debug-symbols -fno-strict-aliasing ... marca@SCML-MarcA:~/src/trafficserver-3.0.2$ grep gethostbyname_r Makefile gethostbyname_r_glibc2 = 1 gethostbyname_r_hostent_data = 1 marca@SCML-MarcA:~/src/trafficserver-3.0.2$ make ... ink_inet.cc: In function 'hostent* ink_gethostbyaddr_r(char*, int, int, ink_gethostbyaddr_r_data*)': ink_inet.cc:73: error: cannot convert 'hostent**' to 'int*' for argument '7' to 'hostent* gethostbyaddr_r(const char*, size_t, int, hostent*, char*, int, int*)' make[3]: *** [ink_inet.lo] Error 1 make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all-recursive] Error 1
Arguably, people should never run configure with CFLAGS=-w and this might seem stupid and something that should never happen, but it turns out that Homebrew (http://mxcl.github.com/homebrew/) does this by default (https://github.com/mxcl/homebrew/issues/9728) – I discovered this while writing a Homebrew formula for Traffic Server (https://github.com/mxcl/homebrew/pull/9513). After discovering that this was causing problems, I modified my formula to tell Homebrew not to do this and all is well, but I thought it would be interesting to make Traffic Server resistant to this as well.
I first tried to enable warnings by trying to find a gcc #pragma that could go in the conftest.c code (http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html looked promising but I could not find one that worked), but I could not find any #pragma that seemed to do this.
I ended up making a small change to `build/common.m4` that strips -w out of CFLAGS using `sed`.
--- build/common.m4.2012-01-22-092051 2011-05-25 13:19:54.000000000 -0700 +++ build/common.m4 2012-01-22 22:48:14.000000000 -0800 @@ -177,6 +177,7 @@ if test "$ac_cv_prog_gcc" = "yes"; then CFLAGS="$CFLAGS -Werror" fi + CFLAGS=$(echo $CFLAGS | sed -e 's/^-w$//' -e 's/^-w //' -e 's/ -w$//' -e 's/ -w / /') AC_COMPILE_IFELSE([AC_LANG_SOURCE([ [#include "confdefs.h" ]