www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - (char* str) is not callable using argument types (string)

reply Zaheer Ahmed <zaheercena gmail.com> writes:
I am Developing and Operation System in D and when writing 
writeln("Zaheer"); function, I got an ERROR.
Error: function kernel.dwriteln (char* str) is not callable using 
argument types (string)
I also tried Casting.
I Developed OS in C and C++ but first time stuck in types.
Jul 17 2017
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 17 July 2017 at 13:56:24 UTC, Zaheer Ahmed wrote:
 I Developed OS in C and C++ but first time stuck in types.
A lot of C and C++ knowledge will carry over to D, but it isn't exactly the same. D's strings are of type `string` which is another word for `immutable(char)[]`. immutable means the contents never change. A `[]` slice is a pointer+length pair in a single type. For your simple case, making it `const char*` should work... but you might want to read up on D's const and array types before going to much further.
Jul 17 2017
next sibling parent Zaheer Ahmed <zaheercena gmail.com> writes:
On Monday, 17 July 2017 at 14:10:39 UTC, Adam D. Ruppe wrote:
 On Monday, 17 July 2017 at 13:56:24 UTC, Zaheer Ahmed wrote:
 I Developed OS in C and C++ but first time stuck in types.
A lot of C and C++ knowledge will carry over to D, but it isn't exactly the same. D's strings are of type `string` which is another word for `immutable(char)[]`. immutable means the contents never change. A `[]` slice is a pointer+length pair in a single type. For your simple case, making it `const char*` should work... but you might want to read up on D's const and array types before going to much further.
Thank you It worked.
Jul 17 2017
prev sibling parent reply Shachar Shemesh <shachar weka.io> writes:
On 07/17/2017 05:10 PM, Adam D. Ruppe wrote:
 On Monday, 17 July 2017 at 13:56:24 UTC, Zaheer Ahmed wrote:
 I Developed OS in C and C++ but first time stuck in types.
A lot of C and C++ knowledge will carry over to D, but it isn't exactly the same. D's strings are of type `string` which is another word for `immutable(char)[]`. immutable means the contents never change. A `[]` slice is a pointer+length pair in a single type. For your simple case, making it `const char*` should work...
No, it shouldn't. Worst, it should work *most* of the time. If you cast a D string to const char* may or may not null terminate the string. Shachar
Jul 17 2017
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 18 July 2017 at 03:58:49 UTC, Shachar Shemesh wrote:
 If you cast a D string to const char* may or may not null 
 terminate the string.
I do not recommend explicitly casting. This specific case is a string literal, which is guaranteed to be null terminated and will implicitly cast. In the cases where it is not null terminated, the compiler will reject it as a type error.
Jul 17 2017