Am Dienstag, 15. Mai 2007 21:28 schrieb Nicholas Clark:
> On Tue, May 15, 2007 at 12:10:09PM -0700, Mike Mattie wrote:
> > If someone remembers the magic to muzzle the compiler around free( from )
> > in memory.c please feel free to amend the patch.
>
> I remember being told that there's a trick involving a union. Something
> like
>
> union {
>   void *out;
>   const void *in;
> } launder;
>
> You assign to in, then read from out. Et voila, you launder the const away.

Well, there is of course ;) such a macro already:

include/parrot/parrot.h:#define const_cast(b) (__ptr_u.__c_ptr = (b), 
__ptr_u.__ptr)

See usage in e.g.

$ grep const_cast src/string.c

> Nicholas Clark

leo

Reply via email to