Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Alex Parrill via Digitalmars-d-learn
On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // error and why ? } Unrelated to your error, but those functions should probably take a `string` and `wstring`

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread riki via Digitalmars-d-learn
On Sunday, 27 December 2015 at 03:40:50 UTC, Alex Parrill wrote: On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // error and why ? } Unrelated to your error, but those

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Basile B. via Digitalmars-d-learn
On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // error and why ? } IDK but usually the const storage class is used for narrow strings because it allows to pass either

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread riki via Digitalmars-d-learn
On Sunday, 27 December 2015 at 04:54:07 UTC, Basile B. wrote: On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // error and why ? } IDK but usually the const storage class

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Basile B. via Digitalmars-d-learn
On Sunday, 27 December 2015 at 04:54:07 UTC, Basile B. wrote: it allows to pass either `char[]` or `string[]`: I meant "char[]` or `string", string without square brackets of course...

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Jimmy Cao via Digitalmars-d-learn
On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // error and why ? } You need to remove the w suffix. Otherwise it is forcibly typed as a dynamic array and is no longer

Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Basile B. via Digitalmars-d-learn
On Sunday, 27 December 2015 at 05:29:44 UTC, riki wrote: On Sunday, 27 December 2015 at 04:54:07 UTC, Basile B. wrote: On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); //