I'm trying to pass a string to a C library through call_external, like this:
result = CALL_EXTERNAL(libname, 'myfunc', 'stringparam')
According to the IDL documentation, the C code should receive an IDL_STRING struct, so I typecast the argument like this:
int myfunc(int argc, char *argv[])
{
IDL_STRING * istr = (IDL_STRING *)argv[0];
// This line is okay:
printf("passed string length = %d\n", istr->slen);
// ********* This line crashes the program!
printf("passed string = %s\n", istr->s);
return 0;
}
When I look at the contents of istr in the VC7 debugger, I see that the string pointer (the 's' member) is 0xbaad0000, a bad pointer.
Can someone tell me what I'm doing wrong? I can get the correct string by passing it by value but that's not an ideal solution because it forces multiple IDL programmers to remember to do so whenever they call a C function that takes a string parameter.
Thanks!
|