shouldn't cast(Object)cast(void*)anything work?
Brad Roberts
braddr at puremagic.com
Wed Apr 4 15:01:09 PDT 2007
On Thu, 5 Apr 2007, Davidl wrote:
> union __exp
> {
> Expression _m_exp;
> int i;
> }
>
> __exp EXP_CANT_INTERPRET;
>
> static this()
> {
> EXP_CANT_INTERPRET.i=1;
> }
>
> and i don't get why i can't use the following work:
>
> //in order to get rid of the runtime extra var
There's no extra 'runtime' anything involved here, just a more concrete
expression of what you're trying to express than casting.
> union _EXP_CANT_INTERPRET // coz we can't use an union as an instance
> {
> Expresssion _m_exp;
> int i=1;
> }
> _EXP_CANT_INTERPRET EXP_CANT_INTERPRET; //compiler complains overlap
> initializer?? strange
>
> and this won't work either:
>
> struct _EXP_CANT_INTERPRET
> {
> union
> {
> Expression _m_exp;
> int i=1; //this would either complain overlap initializer of
> struct _EXP_CANT_INTERPRET
> }
> }
> _EXP_CANT_INTERPRET EXP_CANT_INTERPRET
The 'problem' here is the initializer you've specified on the second
member of the union. Take that out and the message would go away I
suspect. I also suspect, though haven't tried, that if the int i was
first rather than second, that the error would also go away.
Later,
Brad
More information about the Digitalmars-d
mailing list