Chapter 4 Windows3.1 Compiler/Linker Issues
LabWindows/CVI Programmer Reference Manual 4-16
©
National Instruments Corporation

Case 1

Assume the DLL has the following function:

char *f(char *ptr)
{sprintf(ptr, "hello");
return ptr;
}

Then assume that a program in LabWindows/CVI uses the function f as follows:

char buffer[240];
char *bufptr;
bufptr = f(buffer);
printf("%s", bufptr);

You would have to modify the glue code as shown here :

char * f(char *ptr)
{char * retval;
unsigned short cw387;
cw387 = Get387CW();
retval = (char *) InvokeIndirectFunction(__static_f, ptr);
Set387CW(cw387);
retval = MapAliasToFlat(retval); /* Add this line to */
/* glue code. */
return retval;
}

Case 2

Assume the DLL has the following function:

char *f(void)
{char *ptr;
ptr = malloc(100);
sprintf(ptr, "hello");
return ptr;
}
00ProRef.book : 06chap04.fm Page 16 Monday, March 9, 1998 3:23 PM