Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: None <tech-toolchain@NetBSD.org>
From: Simon J. Gerraty <email@example.com>
Date: 07/15/2003 23:40:38
>Use of something like DECONST() can _NEVER_ be correct unless it is
As always, a statement like that is doomed to be wrong.
>'W' on the string constant, rather than to try to pretend that there's
>some magic macro which can be used portably to make string constants
>writable (because as yet there is no such thing). A macro could be used
I don't think anyone apart from you is talking about that.
As far as I know - most of us are talking about drawing the line
_somewhere_ when dealing with 'const'. Ie. there are standard api's out
there that take char *, when they could/should take const char *.
The fact is they don't and unless you have a time machine or a plethora
of spare time/energy and a bunch of pals similarly endowed with time/energy
and nothing better to do... that's not going to change.
So... what do you do when you have a const char *, that you want to pass
to a routine which takes a char * - but _does_not_modify_it_in_any_way_?
Re-writing the target function is out.
Abandoning all use of 'const' is out.
Copying the data - strcpy, etc is insane for the purpose.
So what do you do?
The rest of us use DECONST() or something like that.