<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error using PROC PROTOand FCMP to call an external C function with a struct in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-using-PROC-PROTOand-FCMP-to-call-an-external-C-function/m-p/427014#M281346</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12460"&gt;@jklaverstijn&lt;/a&gt;,&amp;nbsp;At least part of your issue may be related to&amp;nbsp;&lt;A href="http://support.sas.com/kb/56/982.html" target="_self"&gt;this&lt;/A&gt;.&amp;nbsp; I would submit a ticket to SAS Technical Support to corroborate this.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 21:11:28 GMT</pubDate>
    <dc:creator>FriedEgg</dc:creator>
    <dc:date>2018-01-11T21:11:28Z</dc:date>
    <item>
      <title>Error using PROC PROTOand FCMP to call an external C function with a struct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-using-PROC-PROTOand-FCMP-to-call-an-external-C-function/m-p/426890#M281345</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to call&amp;nbsp;functions from a C library and get stuck on a function that returns a pointer to a struct of which&amp;nbsp;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&amp;nbsp;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc proto package=work.proto.cdefs;
   link '/opt/thirdparty/xyz/pqr/bin/libxcpep.so';

   struct stXC_HANDLE {
      double hi;&lt;BR /&gt;      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; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run this I get this log from proc FCMP:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;43         	function sas_xcinitlib(handle, parameter $);
44         	   outargs handle;
45         	   struct stXC_HANDLE handle;
46         	   rc = XCInitLib(handle, parameter);
&lt;FONT color="#FF0000"&gt;ERROR: Cannot promote a scalar to a '**' for argument 1 in function XCInitLib.&lt;/FONT&gt;
47         	   return (rc);
48         	endsub;
49         run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What am I doing wrong here? More specifically:&lt;/P&gt;
&lt;P&gt;- How can I use&amp;nbsp;struct stXC_HANDLE from the external library?&lt;/P&gt;
&lt;P&gt;- How can I avoid the above error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is SAS 9.4M4 on Linux x86_64 (RHEL 7.3).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks in advance for your input,&lt;/P&gt;
&lt;P&gt;-- Jan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-using-PROC-PROTOand-FCMP-to-call-an-external-C-function/m-p/426890#M281345</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2018-01-11T15:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error using PROC PROTOand FCMP to call an external C function with a struct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-using-PROC-PROTOand-FCMP-to-call-an-external-C-function/m-p/427014#M281346</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12460"&gt;@jklaverstijn&lt;/a&gt;,&amp;nbsp;At least part of your issue may be related to&amp;nbsp;&lt;A href="http://support.sas.com/kb/56/982.html" target="_self"&gt;this&lt;/A&gt;.&amp;nbsp; I would submit a ticket to SAS Technical Support to corroborate this.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-using-PROC-PROTOand-FCMP-to-call-an-external-C-function/m-p/427014#M281346</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2018-01-11T21:11:28Z</dc:date>
    </item>
  </channel>
</rss>

