Passing Strings to dll's

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Passing Strings to dll's

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:54 am

by Craig Richardson >> Mon, 15 May 2000 1:38:37 GMT

We are having a bit of trouble trying to send and receive string types from C++ written dll's. Does anyone know what parameter type the C++ side of the code should be set to?

e.g.
Jade....
x:String;
.....
call externFn(x);
.....

C++
void externFn(????)

and the same for receiving from an external function.

Thanks,

Craig

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Passing Strings to dll's

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:54 am

by Krull >> Mon, 15 May 2000 3:20:39 GMT
We are having a bit of trouble trying to send and receive string types from C++ written dll's. Does anyone know what parameter type the C++ side of the code should be set to?

e.g.
Jade....
x:String;
...
call externFn(x);
C++
void externFn(????)

A suitable C++ definition would be:

void externFn(const Character x[])

Where the Character type is type defined to char for an ANSI build and wchar_t for UNICODE as follows:

#if !defined(UNICODE)
typedef char Character;
#else
typedef wchar_t Character;
#endif /* !UNICODE */

and the same for receiving from an external function.

There are a number of different ways to do that; which one is the most appropriate depends a bit on the lifetime of the string and which module 'owns' the string or is responsible for allocating/deallocating the storage. If you can provide an example of how you want to return string data from C/C++, then we can advise on how to best match the JADE declaration with C++. In the meantime, you might obtain some insite from an earlier thread on this newsgroup, subject: "External functions/methods and complex parameters".

cheers
Krull


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 26 guests

cron