On 23.08.2011 00:21, Don Clugston wrote:
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.


Thanks for the quick fix, that brought it back to life.

MAKEINTRESOURCE is used at compile time in the windows headers, e.g.

const RT_CURSOR =           MAKEINTRESOURCE(1);

while I've been using it at runtime in my code, so it's good I don't have to make two different versions of the function.

(Thanks also to Walter for merging it in so fast, I was already wondering how I could get that pull request into my local repo).
_______________________________________________
dmd-beta mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-beta

Reply via email to