De-Referencing A Pointer

Rory Starkweather Rory_member at pathlink.com
Mon Mar 20 23:48:10 PST 2006


Still working on a VB to D DLL interface. I want to pass a string to a D
function. The only way I have been able to do it without errors is ByRef on the
VB end, as expected, to a char* on the D end. However, I want to use the 'find'
function on the string. 'find' requires a char[] and a dchar as inputs. I
haven't been able to figure out how to de-reference the pointer for the char[]
and I don't know how to produce a dchar. 

Here's the code:

//--------DInStr.d-----------
import DLLMain;
import std.string;      // For find

extern (Windows)
{
int findChar(char* searchString)
//int findChar(char[] searchString, dchar searchChar)
{
int iPointer = 0;
char[] eChar = "e";
char[] anotherString;

anotherString = *searchString; //<- Here's the problem

iPointer = find(anotherString, eChar);
// iPointer = find(*searchString, eChar);
// iPointer = find(&searchString, eChar);

return (iPointer);
}
}

The error message is "Cannot explicitly convert expression (*(searchString)) of
type char* to char[]. If I take out the '*' I get about the same thing.

The other problem is the dchar. What can I pass to the function that it will
think is a dchar?

Is there any documentation on this kind of thing? I haven't had much luck
interpreting the language specification.





More information about the Digitalmars-d-learn mailing list