D2 string conversion

Sam Hu samhudotsamhu at gmail.com
Sat May 9 20:48:32 PDT 2009


Hi Sivo & John,

Thank you very much!!!The two versions all work.

But I am a bit confused with the key word *in* in both versions.without them the compiler complained that:

Sivo's version without keyword *in*:
G:\DLang\DEx\D2Ex>dmd d2001.d
d2001.d(32): Error: function d2001.showMessage (wchar[] msg, wchar[] caption = "
Application", int style = 0 | 64) does not match parameter types (immutable(char
)[])
d2001.d(32): Error: cannot implicitly convert expression ("\xe6\x88\x91\xe7\x9a\
x84\xe6\x9c\xaa\xe6\x9d\xa5\xe4\xb8\x8d\xe6\x98\xaf\xe6\xa2\xa6") of type immuta
ble(char)[] to wchar[]

G:\DLang\DEx\D2Ex>

While John's version without keyword *in*:
G:\DLang\DEx\D2Ex>dmd d2001.d
d2001.d(27): Error: function d2001.MessageBoxW (HANDLE, wchar*, wchar*, int) doe
s not match parameter types (HANDLE,immutable(wchar)*,immutable(wchar)*,int)
d2001.d(27): Error: cannot implicitly convert expression (cast(immutable(wchar)*
)(msg ~ "\x00")) of type immutable(wchar)* to wchar*
d2001.d(27): Error: cannot implicitly convert expression (cast(immutable(wchar)*
)(caption ~ "\x00")) of type immutable(wchar)* to wchar*

G:\DLang\DEx\D2Ex>

I am wondering why *in* should have to be used here.

Sam



More information about the Digitalmars-d-learn mailing list