Thread overview
pointers and integers
Dec 29, 2001
Pavel Minayev
Dec 30, 2001
Walter
Dec 30, 2001
Pavel Minayev
December 29, 2001
D doesn't allow to convert integers to pointers. This is great in general, however, I've came to some problems when messing with API - things like MAKEINTRESOURCE and MAKEINTATOM require explicitly defined integer value to be of type char*... not only these, but there are some constants like IDI_APPLICATION that also should be char* while having the very exact value; unfortunately, I don't see any way to do this in D, currently, other than making them all ints and let user do the proper casting where necesarry. Walter, do you have any suggestions how to do this in other way?



December 30, 2001
Hmm, it won't let you do a cast, a-la:

    cast(void*)3

?

"Pavel Minayev" <evilone@omen.ru> wrote in message news:a0lg1n$2c7b$1@digitaldaemon.com...
> D doesn't allow to convert integers to pointers. This is great in general, however, I've came to some problems when messing with API - things like MAKEINTRESOURCE and MAKEINTATOM require explicitly defined integer value to be of type char*... not only these, but there are some constants like IDI_APPLICATION that also should be char* while having the very exact value; unfortunately, I don't see any way to do this in D, currently, other than making them all ints and let user do the proper casting where necesarry. Walter, do you have any suggestions how to do this in other way?
>
>
>


December 30, 2001
"Walter" <walter@digitalmars.com> wrote in message news:a0m78n$2pfo$2@digitaldaemon.com...
> Hmm, it won't let you do a cast, a-la:
>
>     cast(void*)3
>
> ?

Sorry, my fault. The code looked like this:

    const char* a = cast(char*) 666;
    ...
    // a few hundred lines later
    const int b = a;

For some reason, compiler says "unable to cast int to char*" (or whatever it was) pointing at the declaration of a rather than b, even though the latter is wrong...