www.digitalmars.com         C & C++   DMDScript  

D - typedef const bug

reply Pavel Minayev <evilone omen.ru> writes:
Walter=2C try this=3A

=09class Window
=09{
=09=09import windows=3B
=09=09HWND hWnd =3D null=3B
=09}

Error=3A =22non-constant expression cast=28HANDLE=29=28null=29=22=2E

When I cast it explicitly=2C the error is the same=2E HWND
is an alias for HANDLE=2C and HANDLE is typedef'ed
as void*=2E If you make HANDLE alias rather than typedef=2C
it works=2E
Aug 03 2002
parent reply "Walter" <walter digitalmars.com> writes:
typedef needs work :-(

"Pavel Minayev" <evilone omen.ru> wrote in message
news:CFN374715384359838 news.digitalmars.com...
 If you make HANDLE alias rather than typedef,
it works.
Aug 03 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
On Sat, 3 Aug 2002 10:53:53 -0700 "Walter" <walter digitalmars.com> wrote:

 typedef needs work :-(
Then maybe it would be wise to make HANDLE alias for now? So that programs at least work... =)
Aug 03 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:CFN374719723159607 news.digitalmars.com...
 Then maybe it would be wise to make HANDLE alias for now? So that
 programs at least work... =)
Yes. Consider typedef broken for the time being.
Aug 03 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
On Sat=2C 3 Aug 2002 14=3A53=3A17 -0700 =22Walter=22
=3Cwalter=40digitalmars=2Ecom=3E wrote=3A

=3E Yes=2E Consider typedef broken for the time being=2E

By the way=2C the bug seems even more strange=2E You CANNOT cast
null to a HWND=3A

=09const HWND hWnd =3D cast=28HWND=29=28null=29=3B=09=2F=2F doesn't work
=28with or without cast=29

But you CAN cast zero to a HWND=3A

=09const HWND hWnd =3D cast=28HWND=29=280=29=3B=09=2F=2F works!!!

Maybe something's wrong with null=3F
Aug 03 2002
parent "Walter" <walter digitalmars.com> writes:
I'll check it out.

"Pavel Minayev" <evilone omen.ru> wrote in message
news:CFN37472106677037 news.digitalmars.com...
By the way, the bug seems even more strange. You CANNOT cast
null to a HWND:

const HWND hWnd = cast(HWND)(null); // doesn't work (with or without cast)

But you CAN cast zero to a HWND:

const HWND hWnd = cast(HWND)(0); // works!!!

Maybe something's wrong with null?
Aug 03 2002