Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: NetBSD Toolchain Technical Discussion List <tech-toolchain@NetBSD.ORG>
From: Greg A. Woods <woods@weird.com>
List: tech-toolchain
Date: 07/11/2003 19:08:49
[ On Friday, July 11, 2003 at 20:31:43 (GMT), Christos Zoulas wrote: ]
> Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
>
> In article <20030711171907.468B6206B2@frodo.juniper.net>,
> Simon Gerraty <sjg@juniper.net> wrote:
> >
> > and inevitably you need to be able to discard const without a simple
> > cast to be safe.  A static inline func discard_const() works well,
> > but I don't see evidence that we condone use of those.
> > I'm painfully aware that over use of static inlines leads to debug
> > hell.

A far as I know the only sure and portable way to discard a const
qualifier on some storage area is to allocate new non-const storage area
and copy the const data into the new non-const storage.

This gets extremely painful when all you're trying to do is shut up the
stupid compiler from complaining about string constants or the like, but
the only portable alternative is to qualify the parameter as const (and
hope it really won't be modified! ;-).

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>