<?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>tópico Re: accessing an array via pointer returned from C++ routine na Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946897#M18488</link>
    <description>Thanks John,  that got it!</description>
    <pubDate>Sat, 14 Apr 2001 00:16:30 GMT</pubDate>
    <dc:creator>stober123</dc:creator>
    <dc:date>2001-04-14T00:16:30Z</dc:date>
    <item>
      <title>accessing an array via pointer returned from C++ routine</title>
      <link>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946893#M18484</link>
      <description>I am trying to get to the data in array that is created in a COM application.  The interface routine specifies a return argument that is a pointer to a pointer to the data array.  Is it even possible to access this data via FORTRAN? &lt;BR /&gt;Any ideas?</description>
      <pubDate>Thu, 12 Apr 2001 06:25:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946893#M18484</guid>
      <dc:creator>stober123</dc:creator>
      <dc:date>2001-04-12T06:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: accessing an array via pointer returned from C++ routine</title>
      <link>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946894#M18485</link>
      <description>Yes it is possible.  For best results post the IDL and optionally the C++ prototype.  What f90 code did the Module Wizard produce for this routine? (I'd post that too) &lt;BR /&gt; &lt;BR /&gt;-John</description>
      <pubDate>Thu, 12 Apr 2001 06:54:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946894#M18485</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-12T06:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: accessing an array via pointer returned from C++ routine</title>
      <link>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946895#M18486</link>
      <description>I can supply the module wizard code, the C++ code is not mine, I'll have to look around for the IDL. &lt;BR /&gt;Wizard Code: &lt;BR /&gt; INTEGER*4 FUNCTION $IOPCGroup_SyncWrite($OBJECT, NumItems, ServerHandles, Values, Errors) &lt;BR /&gt;!DEC$ ATTRIBUTES DLLEXPORT	:: $IOPCGroup_SyncWrite &lt;BR /&gt;IMPLICIT NONE &lt;BR /&gt;	 &lt;BR /&gt;INTEGER(INT_PTR_KIND()), INTENT(IN)	:: $OBJECT	 ! Object Pointer &lt;BR /&gt;!DEC$ ATTRIBUTES VALUE	:: $OBJECT &lt;BR /&gt;INTEGER*4, INTENT(IN)	:: NumItems	 &lt;BR /&gt;!DEC$ ATTRIBUTES REFERENCE	:: NumItems &lt;BR /&gt;INTEGER(INT_PTR_KIND()), INTENT(IN)	:: ServerHandles	! (SafeArray) &lt;BR /&gt;!DEC$ ATTRIBUTES REFERENCE	:: ServerHandles &lt;BR /&gt;INTEGER(INT_PTR_KIND()), INTENT(IN)	:: Values	! (SafeArray) &lt;BR /&gt;!DEC$ ATTRIBUTES REFERENCE	:: Values &lt;BR /&gt;INTEGER(INT_PTR_KIND()), INTENT(OUT)	:: Errors	! (SafeArray) &lt;BR /&gt;!DEC$ ATTRIBUTES REFERENCE	:: Errors &lt;BR /&gt;INTEGER*4 $RETURN &lt;BR /&gt;INTEGER(INT_PTR_KIND()) $VTBL			! Interface Function Table &lt;BR /&gt;POINTER($VPTR, $VTBL) &lt;BR /&gt;$VPTR = $OBJECT			! Interface Function Table &lt;BR /&gt;$VPTR = $VTBL + 112	! Add routine table offset &lt;BR /&gt;IOPCGroup_SyncWrite_PTR = $VTBL &lt;BR /&gt;$RETURN = IOPCGroup_SyncWrite($OBJECT, NumItems, ServerHandles, Values, Errors) &lt;BR /&gt;$IOPCGroup_SyncWrite = $RETURN &lt;BR /&gt;END FUNCTION $IOPCGroup_SyncWrite &lt;BR /&gt; &lt;BR /&gt;I have tried this using the SAFEARRAY's, it works when run in the debugger, when run outside of the debugger it hangs in above write stmt.  If I replace the Errors argument with a I*4 variable and ignore it (ie don't bother checking the values) everything is fine.  This is possibly a memory corruption issue (the hang), but it is impossible to locate when everything runs fine in the debugger.</description>
      <pubDate>Thu, 12 Apr 2001 07:20:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946895#M18486</guid>
      <dc:creator>stober123</dc:creator>
      <dc:date>2001-04-12T07:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: accessing an array via pointer returned from C++ routine</title>
      <link>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946896#M18487</link>
      <description>Errors is an explicit intent out safearray. So I'd bet that the COM method is allocating the memory for it (calling SafeArrayCreate) and passing it out - your description of what happens when you pass an int for Errors supports this too. You need to know this for certain. It is part of the semantic contract of the interface.  &lt;BR /&gt; &lt;BR /&gt;In your call to $IOPCGroup_SyncWrite you want ServerHandles and Values to be integer variables that hold pointers to SafeArrays that you have created and initialized. Errors should be an integer variable that you have initialized to some value (zero). On return, Errors should hold a valid pointer to a SafeArray that you could inspect if you'd like to.  &lt;BR /&gt; &lt;BR /&gt;If I am inferring properly from your posting, I'd do something like:  &lt;BR /&gt;&lt;PRE&gt; 
! ...  
 
real :: Errors(NumItems)  ! if Errors is of type real  
 
pointer (pErrors, Errors)  
 
integer :: psaOut  
 
! ...  
 
psaOut = 0  
 
hr = $IOPCGroup_SyncWrite (pIopcgroup, NumItems, psaHandles, psaValues, psaOut)  
 
if (hr &amp;gt;=0) then 
  hr = SafeArrayAccessData(psaOut, pErrors)  
      ! examine Errors in here.  
  hr = SafeArrayUnAccessData(psaOut)  
 
! ... 
 
&lt;/PRE&gt; &lt;BR /&gt;hth,  &lt;BR /&gt;John</description>
      <pubDate>Fri, 13 Apr 2001 02:35:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946896#M18487</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-13T02:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: accessing an array via pointer returned from C++ routine</title>
      <link>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946897#M18488</link>
      <description>Thanks John,  that got it!</description>
      <pubDate>Sat, 14 Apr 2001 00:16:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/accessing-an-array-via-pointer-returned-from-C-routine/m-p/946897#M18488</guid>
      <dc:creator>stober123</dc:creator>
      <dc:date>2001-04-14T00:16:30Z</dc:date>
    </item>
  </channel>
</rss>

