04-16-2010 07:30 AM
Hallo,
I found an example for calling void c function(http://zone.ni.com/devzone/cda/epd/p/id/1513). I could adapt the example and make the function return an integer. the code of the adapted function would look like this:
int __declspec(dllexport) multiply(int number)
{
return number*3;}
But I have problems when I want to return a string. Does someone knows how I should do. I tried:
char* __declspec(dllexport) say(int number)
{
return "hallo";}
but won't compile.
04-16-2010 08:05 AM
I haven't worked with C-connections or dll's much, but technically you're not returning a string, but a character pointer. As such you get the adress where the string starts as an integer. You'll need to typecast the int-adress to a string.
Check your code when running and i'm sure the C-call returns a 32-bit int alot bigger than a normal character.
/Y
04-16-2010 08:34 AM
davico wrote:
but won't compile.
Are you asking a C question, or a LabVIEW question? What's the error message?
04-16-2010 09:27 AM
yes the question was more a c question then a labview question. I found the solution anyway, the correct code in order to get string is:
_declspec(dllexport) char* testchar2();
_declspec(dllexport) char* testchar2(){
return "hallo";}