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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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