string to char*

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Sep 11 07:05:00 PDT 2010


I'm interfacing with Scintilla (C++), but it works in a different way.
It uses messages, which allows it to be linked with practically any
language. But I can still pass parameters to be modified by passing
the address of the variable instead (the wrapper takes care of that).

Although linking with C++ is difficult, having proper C linkage is a
great thing. There's a ton of libraries out there ready to be used
right now in D.

2010/9/11 Mariusz Gliwiński <alienballance at gmail.com>:
> On 2010-09-11 15:13, Simen kjaeraas wrote:
>>
>> Why does the function expect a char*? If it is an external C function,
>> and it might change the passed values, you should make a duplicate
>> mutable string, or use char[] in lieu of string.
>>
>> If it is an external C function that will *not* change the passed
>> values, and you have write access to the D headers to interface to C,
>> use const char* instead. If no write access, I would use
>> cast(char*)myString.ptr.
>
> Yes, it's external C function and I can modify bindings (just bindings, not
> ABI). Now I'll trace back library which is interfacing to me and possibly
> fix bindings.
>
> You helped me already, thanks a lot. I can already go on (this language is
> so cool btw.).
>


More information about the Digitalmars-d-learn mailing list