BookmarkSubscribeRSS Feed
jklaverstijn
Rhodochrosite | Level 12

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.

 

1 REPLY 1
FriedEgg
SAS Employee

@jklaverstijn, At least part of your issue may be related to this.  I would submit a ticket to SAS Technical Support to corroborate this.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 302 views
  • 1 like
  • 2 in conversation