Getting a reference to an immutable string
ag0aep6g
anonymous at example.com
Sat Feb 10 22:59:18 UTC 2018
On 02/10/2018 11:46 PM, David Zhang wrote:
> This is what I'm talking about:
>
> void createWindow( ... ) {
>
> assert( wndclassName.ptr ); //This fails
>
> HWND hwnd = CreateWindowW(
> wndclassName.ptr, //This too
> null,
> 0,
> CW_USEDEFAULT, CW_USEDEFAULT,
> CW_USEDEFAULT, CW_USEDEFAULT,
> null,
> null,
> null,
> null
> );
> }
>
> wstring wndclassName = "wndclass_name"w;
That's not enough code to reproduce the issue. This works as far as I see:
----
import core.sys.windows.windef: HWND;
import core.sys.windows.winuser: CreateWindowW, CW_USEDEFAULT;
void main()
{
assert( wndclassName.ptr );
HWND hwnd = CreateWindowW(
wndclassName.ptr,
null,
0,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
null,
null,
null,
null
);
}
wstring wndclassName = "wndclass_name"w;
----
But there is a recent regression on Windows that might be related. Do
you also have a static constructor (`static this`) that uses
`wndclassName`? If so, you might be hitting issue 18412.
https://issues.dlang.org/show_bug.cgi?id=18412
If you don't have a static constructor, it might be a different bug. In
that case, please provide complete code so that we can get to the bottom
of it.
More information about the Digitalmars-d-learn
mailing list