On 20 August 2011 10:39, Rainer Schuetze <[email protected]> wrote:
> Hi,
>
> I recently updated to the latest revision from github and tried to compile
> my main project visuald with it. Here are some complications that have hit
> me:
>
> 1. My Windows SDK conversion tool converts C macros to templates, e.g.
>
> #define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i))))
>
> is converted to
>
> auto MAKEINTRESOURCEW(ARG)(ARG i)() { return ( cast(LPWSTR)(
> cast(ULONG_PTR)( cast(WORD)(i)))); }
>
> This no longer works for CTFE, because casts to pointers are no longer
> allowed. Making the argument a template parameter still works, though:
>
> auto MAKEINTRESOURCEW(int i)() { return ( cast(LPWSTR)( cast(ULONG_PTR)(
> cast(WORD)(i)))); }
>
> Also, casting to a pointer is still allowed when initializing a global
> variable at compile time.
>
> Is this by design or a regression?

It was by design. The casting to pointer when initializing globals is
precisely because of these Windows casts.
Previously, the MAKEINTRESOURCEW function seemed to work but didn't do
what you'd expect. In many cases, instead of a constant, you were
getting a runtime function call to the  MAKEINTRESOURCEW function...
But I've just created a pull request
(https://github.com/D-Programming-Language/dmd/pull/326) which (among
other things) will allow your function to work in CTFE.
_______________________________________________
dmd-beta mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-beta

Reply via email to