C to D struct including LPVOID,LPCSTR

Steve Horne stephenwantshornenospam100 at aol.com
Sun Sep 10 03:46:13 PDT 2006


On Sat, 09 Sep 2006 22:53:06 +0200, BLS <nanali at wanadoo.fr> wrote:

>How do I translate : LPCSTR

That means 'pointer to a C string'.

One possible answer is char*.

D can handle C strings. If you do this, the pointer points to the
first character of the string which is null terminated. It is possible
to access the C string library from D, IIRC, but you have the same
responsibilities as you would in C, like making sure the memory
allocated for the string is big enough.

With Windows API stuff, you're probably stuck with this.

If you can change the type of the string, though, consider using
char[] - a D string. It still operates as an array of characters, but
D arrays are better.

IIRC there is an implicit pointer in there (the string itself wouldn't
end up in the struct) so the struct will still be the same size.

>What else is wrong.

I hate that C/C++ compatibility typedef/struct syntax. Confuses me
every time - I start thinking of the syntax where you declare a struct
and an instance of that struct in one go :-(

I think you're OK, though.

-- 
Remove 'wants' and 'nospam' from e-mail.



More information about the Digitalmars-d-learn mailing list