[dmd-beta] Time for a new beta?

Don Clugston dclugston at googlemail.com
Mon Aug 22 15:21:59 PDT 2011


On 20 August 2011 10:39, Rainer Schuetze <r.sagitario at gmx.de> 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.


More information about the dmd-beta mailing list