Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

calling cxml.dll from c++

danial
Beginner
669 Views
i am calling ISAMAX in cxml.dll from c++ dynamically loading the library well enough and finding function ok. but i am getting an err: referenced memory can't be read. here is the code:
typedef long( *p)(long, float [], long);
p ISAMAX;
HINSTANCE hLib;
hLib = LoadLibrary("C:\CXML.DLL");
ISAMAX = (p)GetProcAddress(hLib,"ISAMAX");
long n = 2;
long incx = 1;
float arr[2];
arr[0] = 1;
arr[1] = 2;
imax = ((ISAMAX)(n, arr, incx));
FreeLibrary(hLib);

I have also tried passing n and incx by reference, but no good. Does anyone have an idea as to what I am doing wrong?
0 Kudos
2 Replies
Steven_L_Intel1
Employee
669 Views
I note you're not checking the return statuses - CXML.DLL isn't usually in C: Also, you have to call the CXML routines with STDCALL mechanism - I don't know offhand how to express that in C++ for this case.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
669 Views
It's one of uglier aspects of C syntax (I will never remember it -- always have to do a copy&paste):
typedef long(__stdcall *p)(long*, float [], long*);
Jugoslav

0 Kudos
Reply