Subject: Re: __UNCONST(a)
To: None <tech-userlevel@NetBSD.org>
From: James K. Lowden <jklowden@schemamania.org>
List: tech-userlevel
Date: 07/03/2004 15:28:47
On Thu, 1 Jul 2004 Christos Zoulas wrote:
> On Jul 2, 10:06am, yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
>
> | > Why cast to a specific type? We could do the same, but it seems
> | > gratuitous.
> |
> | because it's only sane way without typeof().
>
> Why, (void *) matches everything.
You want to defeat the whole type system, merely to quell compiler
warnings?
wchar_t *ws;
const char s[] = "hello";
ws = __UNCONST(s);
This is good? I realize that's not the intended context, but there's
nothing except vigilance to prevent it from being used that way, and
vigilance breaks down in complex situations.
C++ uses const_cast<>, providing a type. Seems a like a good model to
follow.
--jkl