Subject: Re: __UNCONST(a)
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 06/30/2004 21:48:58
On Tue, Jun 29, 2004 at 11:53:25PM -0400, Christos Zoulas wrote:
> 
> I would like to add:
> 
>     /* No intptr_t dependency here */
>     #define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
> 
> Any objections?

Why not:

#define __UNCONST(a) ((void *)(((const char *)(a) - (const char *)0) + (char *)0))

Which does away with requiring an integral type.

Or better still the inline function:

static inline void *
__UNCONST(const void *a)
{
    return ((const char *)a - (const char *)0) + (char *)0;
}

Which will validate that the supplied parameter is a pointer type.

	David

-- 
David Laight: david@l8s.co.uk