Hi,
I am trying to call functions from a C library and get stuck on a function that returns a pointer to a struct of which the definition is hidden inside compiled code. I use PROC PROTO and PROC FCMP for this after failing with MODULEN() (another story). There are many functions in the library. Another one worked but has a very simple definition. My code is below. I have added a bogus definition for the struct stXC_HANDLE as I have no idea either how to get that from the external library.
proc proto package=work.proto.cdefs;
link '/opt/thirdparty/xyz/pqr/bin/libxcpep.so';
struct stXC_HANDLE {
double hi; long * low;
};
typedef struct stXC_HANDLE *XC_HANDLE;
typedef char XC_CHAR;
int XCInitLib(XC_HANDLE* phXCHandle, const XC_CHAR* pcParameter);
run;
proc fcmp inlib=work.proto outlib=work.proto.fcmp;
function sas_xcinitlib(handle, parameter $);
outargs handle;
struct stXC_HANDLE handle;
rc = XCInitLib(handle, parameter);
return (rc);
endsub;
run;
options cmplib=(work.fcmp work.proto);
data _null_;
length parameter $20;
parameter = '';
handle = 0x;
rc_init = sas_xcinitlib(addrlong(handle), parameter);
put _all_;
run;
When I run this I get this log from proc FCMP:
43 function sas_xcinitlib(handle, parameter $);
44 outargs handle;
45 struct stXC_HANDLE handle;
46 rc = XCInitLib(handle, parameter);
ERROR: Cannot promote a scalar to a '**' for argument 1 in function XCInitLib.
47 return (rc);
48 endsub;
49 run;
What am I doing wrong here? More specifically:
- How can I use struct stXC_HANDLE from the external library?
- How can I avoid the above error?
This is SAS 9.4M4 on Linux x86_64 (RHEL 7.3).
Many thanks in advance for your input,
-- Jan.
... View more