digitalmars.D - (char* str) is not callable using argument types (string)
- Zaheer Ahmed (6/6) Jul 17 2017 I am Developing and Operation System in D and when writing
- Adam D. Ruppe (9/10) Jul 17 2017 A lot of C and C++ knowledge will carry over to D, but it isn't
- Zaheer Ahmed (2/12) Jul 17 2017 Thank you It worked.
- Shachar Shemesh (6/18) Jul 17 2017 No, it shouldn't.
- Adam D. Ruppe (6/8) Jul 17 2017 I do not recommend explicitly casting. This specific case is a
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
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
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:Thank you It worked.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
On 07/17/2017 05:10 PM, Adam D. Ruppe wrote:On Monday, 17 July 2017 at 13:56:24 UTC, Zaheer Ahmed wrote: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. ShacharI 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...
Jul 17 2017
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