Subject: Re: Cannot compile C++ programs with WARNS > 3 on 4.0_BETA2
To: Hubert Feyrer <hubert@feyrer.de>
From: Jeremie Le Hen <jeremie@le-hen.org>
List: tech-misc
Date: 01/22/2007 18:34:03
Hubert,

On Mon, Jan 22, 2007 at 05:55:55PM +0100, Hubert Feyrer wrote:
> On Mon, 22 Jan 2007, Jeremie Le Hen wrote:
> >% c++ -O2 -Wall -Wpointer-arith -Wno-sign-compare -Wreturn-type -Wswitch 
> >-Wshadow -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter 
> >-std=gnu99 -Werror   -Wabi -Wold-style-cast -Wctor-dtor-privacy 
> >-Wnon-virtual-dtor -Wreorder  -Wno-deprecated -Wno-non-template-friend  
> >-Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo -Wsynth     -c    
> >zthreadstub.cc
> ...
> >% cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC 
> >but not for C++
> ...
> >The fix is trivial and the patch is following:
> [drop -std=gnu99 from CXXFLAGS]
> 
> Why do you think it's better to make the system headers drop a wrongly 
> used option? Personally, I'd say you shouldn't use that option, as the 
> error/warning says.
> 
> (other lists that may be relevant for are tech-toolchain@ and 
> tech-userlevel@).

Sorry, I should have explained better the problem.  Here is my
Makefile:

% PROG_CXX=       zthreadstub
% SRCS=           zthreadstub.cc
% INCS=           zthreadstub.hh
% MAN=
% DEBUG_FLAGS=    -g
% WARNS=          6
% LDADD=          -lpthread
% 
% OBJS+=          threadpool.o
% threadpool.o:   threadpool/threadpool.c
% 
% .include <bsd.prog.mk>

As you can see, I don't fiddle CFLAGS at all.  Actually the system is
adding --std=gnu99 itself in share/mk/bsd.sys.mk:

% octobrebsd:mk# grep -C 1 gnu99 bsd.sys.mk
% .if ${WARNS} > 3 && ${HAVE_GCC} >= 3
% CFLAGS+=        -std=gnu99
% .endif

Whereas share/mk/sys.mk makes CXXFLAGS depends on CFLAGS:

% octobrebsd:mk# grep ^CXXFLAGS sys.mk
% CXXFLAGS?=      ${CFLAGS:N-Wno-traditional:N-Wstrict-prototypes:N-Wmissing-prototypes}


Thus my fix:

-CXXFLAGS?=     ${CFLAGS:N-Wno-traditional:N-Wstrict-prototypes:N-Wmissing-prototypes}
+CXXFLAGS?=     ${CFLAGS:N-Wno-traditional:N-Wstrict-prototypes:N-Wmissing-prototypes:N-std=gnu99}


I hope I am not misunderstanding something.
Best regards,
-- 
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >