Subject: Re: __UNCONST(a)
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 07/02/2004 01:36:47
>>>>> #define	__DECONST(type, var)	((type)(uintptr_t)(const void *)(var))
>>>> Why cast to a specific type?
>>> because it's only sane way without typeof().
>> What's insane about just making it produce a void *?
> - in most cases, what you want is a specific type, isn't it?

Yes, but it's usually "the type of this thingy", and having to go look
up what type the thingy actually is is a pain - especially if there's
any significant chance that type's textual name will change.

If I had to use a __DECONST like that, I would almost certainly wrap a
DECONST() around it that simply provided void * as the type.

> - it strips out other qualifiers like volatile.
>   (typeof() isn't enough for this either.)

It also has nothing to do with using - or not using - void *.

Actually, I usually want to strip all qualifiers.  const simply happens
to be the most relevant one because it's the one for which poisoning is
most important.  In a few programs I've used a deconst-alike that takes
const volatile void * and returns void *.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B