Re: [Exim] Using int vs. size_t in Exim

Góra strony
Delete this message
Reply to this message
Autor: Exim Users Mailing List
Data:  
Dla: exim-users
Temat: Re: [Exim] Using int vs. size_t in Exim
[ On Wednesday, April 9, 2003 at 14:34:27 (+0100), Philip Hazel wrote: ]
> Subject: Re: [Exim] Using int vs. size_t in Exim
>
> On 9 Apr 2003 michael@??? wrote:
>
> > It turns out that gcc 3.2.2 on different operating systems differs by
> > needing -pedantic on some systems to get that warning, which explains
> > why I did not see it before (Exim does not use -pedantic).
>
> Sigh. I wish compilers would default to 'all warnings ON'. I will try
> -pedantic on my test compiles to see what it throws up. Currently I just
> use -Wall.


I find -pedantic pretty useless, but there are lots of other important
checks that can be enabled in GCC, including and especially plain "-W".

You should use 'lint' too of course. A really good compiler may not
ever spit out any warnings like GCC does, only stop on the fatal errors
it cannot cope with. Lint is the tool that should always be used for
real code consistency and portablity checking. There are even newer
varieties of lint, such as lclint, which claim to do even better safety
checking than plain old lint.

Here's a *BSD Pmake Makefile fragment I use. It leverages off some
NetBSD and FreeBSD /usr/share/mk/* features, but it will, with the
appropriate pre-set macros (e.g. __NetBSD__, __GNUC__, etc.) do the
right thing even on stock 4.4BSD:

# GCC apparently has buggy parameter width detection
NOGCCERROR = 1
NO_WERROR = 1

# Take control of our own warning flags (WARNS=2 is not yet appropriate)
WARNS = 0

# no, we're not that pedantic!
#CWARNFLAGS += -pedantic
#
CWARNFLAGS += -W
CWARNFLAGS += -Wall
#
# these aren't always in "-Wall"
CWARNFLAGS += -Wimplicit
CWARNFLAGS += -Wreturn-type
CWARNFLAGS += -Wswitch
CWARNFLAGS += -Wcomment
#
# in addition to -Wall
CWARNFLAGS += -Wcast-qual
# -Wid-clash-LEN is sadly no longer supported in 3.2.2
CWARNFLAGS += -Wid-clash-30
CWARNFLAGS += -Wpointer-arith
CWARNFLAGS += -Wshadow
#
# I'm not quite ready for full const-ification yet...
#CWARNFLAGS += -Wwrite-strings
#
# this isn't mentioned in 1.42's manual but causes no error
CWARNFLAGS += -Wstrict-prototypes

__GNUC__ ?= 1
.if $(__GNUC__) >= 2
CWARNFLAGS += -Waggregate-return
CWARNFLAGS += -Wchar-subscripts
# WARNING: GCC is broken w.r.t. complaining about integer types narrower than int
CWARNFLAGS += -Wconversion
CWARNFLAGS += -Wmissing-declarations
CWARNFLAGS += -Wmissing-prototypes
CWARNFLAGS += -Wno-format-extra-args
# the rest aren't in the manual, but work on at least 2.9x.x
# -Wundef isn't in 2.7.2, but if you're still using 2.7.2 you may be
# suffering from far more bugs and problems than you might know!
CWARNFLAGS += -Wundef
CWARNFLAGS += -Wlarger-than-65536
CWARNFLAGS += -Wbad-function-cast
.endif
.if $(__GNUC__) >= 3
# Yuck: this is broken in at least 3.2.2...
#CWARNFLAGS += -Wunreachable-code
.endif

WFORMAT = 0
.if defined(__NetBSD__) && $(CC) == "cc"
# Some magic is missing -- I can't always get this to shut up....
# (warning: non-constant format parameter)
CWARNFLAGS += -Wnetbsd-format-audit
.elif defined(__FreeBSD__)
# Some magic is missing -- I can't always get this to shut up....
CWARNFLAGS += -Wnon-const-format
# (warning: non-constant format parameter)
.endif

.if !defined(__NetBSD__) && !defined(__FreeBSD__)
CFLAGS += $(CWARNFLAGS)
.endif


--
                                Greg A. Woods


+1 416 218-0098;            <g.a.woods@???>;           <woods@???>
Planix, Inc. <woods@???>; VE3TCP; Secrets of the Weird <woods@???>