<?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 IntPtr troubles with VB .Net 2005 in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/IntPtr-troubles-with-VB-Net-2005/m-p/863041#M7986</link>
    <description>&lt;P&gt;I am doing a migration of some MS/VS 2003 C++ code to MS/VS 2005 Visual Basic. The code references some IPP Signal Processing Library routines. To make matters more complicated, the legacy C++ code references version 4.x of the library, and I am using version 5.1.&lt;/P&gt;
&lt;P&gt;I have arrived at a point where most of the compiler errors have been addressed, but there are a couple that just won't go away. The biggest problem has to do with passing an array of doubles to routines which expect a type IntPtr.&lt;/P&gt;
&lt;P&gt;Following are some code-fragments to illustrate the issue(s). In most cases I have included the legacy C++ code as comments.&lt;/P&gt;
&lt;P&gt;Focus here on the declaration of dWinData.&lt;/P&gt;
&lt;P&gt;'double WindowFunction&lt;BR /&gt;' (&lt;BR /&gt;' short intWindowOption,&lt;BR /&gt;' long lFFTSize,&lt;BR /&gt;' double *dSignalCorrectiondB,&lt;BR /&gt;' double *dNoiseCorrectiondB,&lt;BR /&gt;' double *dWinData&lt;BR /&gt;' )&lt;BR /&gt;Public Function WindowFunction( _&lt;BR /&gt; ByVal intWindowOption As Short, _&lt;BR /&gt; ByVal lFFTSize As Integer, _&lt;BR /&gt; ByRef dSignalCorrectiondB As Double, _&lt;BR /&gt; ByRef dNoiseCorrectiondB As Double, _&lt;BR /&gt; ByRef dWinData() As Double _&lt;BR /&gt; ) As Double&lt;/P&gt;
&lt;P&gt;Here dWinData is passed as a pointer to a double (or array of doubles) in the original C code. In my VB code I have declared dWinData to be an array of doubles, passed by reference. When I get to the following statement...&lt;/P&gt;
&lt;P&gt;'inStatus = ippsSet_64f(1.0, dWinData, lFFTSize); //Set elements of dWinData = 1.0&lt;BR /&gt;inStatus = ipp.sp.ippsSet_64f(1.0, dWinData, lFFTSize)&lt;/P&gt;
&lt;P&gt;... the compiler complains about dWinData: "... Value of type '1-dimensional array of Double' cannot be converted to 'System.IntPtr'...". For reference, the declaration of ippsSet_64f is &lt;/P&gt;
&lt;P&gt;Declare Function ippsSet_64f Lib "ipps-5.1.dll" _&lt;BR /&gt;( ByVal val As Double , ByVal pDst As IntPtr , ByVal len As Integer ) As IppStatus&lt;/P&gt;
&lt;P&gt;Note that ippsSet_64f expects the second passed parameter to be of type IntPtr.&lt;/P&gt;
&lt;P&gt;What can I do about this?&lt;/P&gt;
&lt;P&gt;My background is that I am very familiar with C and VB6,a littlefamiliar with C++ and just getting up to speed with .Net and the VS 2005 development environment.&lt;/P&gt;
&lt;P&gt;Any assistance is greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 11 May 2007 19:41:06 GMT</pubDate>
    <dc:creator>cernek</dc:creator>
    <dc:date>2007-05-11T19:41:06Z</dc:date>
    <item>
      <title>IntPtr troubles with VB .Net 2005</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/IntPtr-troubles-with-VB-Net-2005/m-p/863041#M7986</link>
      <description>&lt;P&gt;I am doing a migration of some MS/VS 2003 C++ code to MS/VS 2005 Visual Basic. The code references some IPP Signal Processing Library routines. To make matters more complicated, the legacy C++ code references version 4.x of the library, and I am using version 5.1.&lt;/P&gt;
&lt;P&gt;I have arrived at a point where most of the compiler errors have been addressed, but there are a couple that just won't go away. The biggest problem has to do with passing an array of doubles to routines which expect a type IntPtr.&lt;/P&gt;
&lt;P&gt;Following are some code-fragments to illustrate the issue(s). In most cases I have included the legacy C++ code as comments.&lt;/P&gt;
&lt;P&gt;Focus here on the declaration of dWinData.&lt;/P&gt;
&lt;P&gt;'double WindowFunction&lt;BR /&gt;' (&lt;BR /&gt;' short intWindowOption,&lt;BR /&gt;' long lFFTSize,&lt;BR /&gt;' double *dSignalCorrectiondB,&lt;BR /&gt;' double *dNoiseCorrectiondB,&lt;BR /&gt;' double *dWinData&lt;BR /&gt;' )&lt;BR /&gt;Public Function WindowFunction( _&lt;BR /&gt; ByVal intWindowOption As Short, _&lt;BR /&gt; ByVal lFFTSize As Integer, _&lt;BR /&gt; ByRef dSignalCorrectiondB As Double, _&lt;BR /&gt; ByRef dNoiseCorrectiondB As Double, _&lt;BR /&gt; ByRef dWinData() As Double _&lt;BR /&gt; ) As Double&lt;/P&gt;
&lt;P&gt;Here dWinData is passed as a pointer to a double (or array of doubles) in the original C code. In my VB code I have declared dWinData to be an array of doubles, passed by reference. When I get to the following statement...&lt;/P&gt;
&lt;P&gt;'inStatus = ippsSet_64f(1.0, dWinData, lFFTSize); //Set elements of dWinData = 1.0&lt;BR /&gt;inStatus = ipp.sp.ippsSet_64f(1.0, dWinData, lFFTSize)&lt;/P&gt;
&lt;P&gt;... the compiler complains about dWinData: "... Value of type '1-dimensional array of Double' cannot be converted to 'System.IntPtr'...". For reference, the declaration of ippsSet_64f is &lt;/P&gt;
&lt;P&gt;Declare Function ippsSet_64f Lib "ipps-5.1.dll" _&lt;BR /&gt;( ByVal val As Double , ByVal pDst As IntPtr , ByVal len As Integer ) As IppStatus&lt;/P&gt;
&lt;P&gt;Note that ippsSet_64f expects the second passed parameter to be of type IntPtr.&lt;/P&gt;
&lt;P&gt;What can I do about this?&lt;/P&gt;
&lt;P&gt;My background is that I am very familiar with C and VB6,a littlefamiliar with C++ and just getting up to speed with .Net and the VS 2005 development environment.&lt;/P&gt;
&lt;P&gt;Any assistance is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2007 19:41:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/IntPtr-troubles-with-VB-Net-2005/m-p/863041#M7986</guid>
      <dc:creator>cernek</dc:creator>
      <dc:date>2007-05-11T19:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: IntPtr troubles with VB .Net 2005</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/IntPtr-troubles-with-VB-Net-2005/m-p/863042#M7987</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;You should use &lt;SPAN id="nsrTitle"&gt;Marshal.UnsafeAddrOfPinnedArrayElement method&lt;/SPAN&gt; to get the address of the element inside the specified array similarly to the following code:&lt;/P&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;Dim&lt;/FONT&gt;&lt;FONT size="2"&gt; dWinData() &lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;As&lt;/FONT&gt;&lt;FONT size="2"&gt; &lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;Double&lt;/FONT&gt;&lt;FONT size="2"&gt; = {0, 0, 0, 0, 0}&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" size="2"&gt;Dim&lt;/FONT&gt;&lt;FONT size="2"&gt; pdWinData &lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;As&lt;/FONT&gt;&lt;FONT size="2"&gt; IntPtr = Marshal.UnsafeAddrOfPinnedArrayElement(dWinData, 0)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;inStatus= ipp.sp.ippsSet_64f(1.0, pdWinData, dWinData.Length)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Albert&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2007 07:03:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/IntPtr-troubles-with-VB-Net-2005/m-p/863042#M7987</guid>
      <dc:creator>Albert_Stepanov</dc:creator>
      <dc:date>2007-05-14T07:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: IntPtr troubles with VB .Net 2005</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/IntPtr-troubles-with-VB-Net-2005/m-p/863043#M7988</link>
      <description>&lt;P&gt;Hi Albert, Thank you. The compiler likes it. Now I see whether it works...&lt;/P&gt;
&lt;P&gt;EdC&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2007 16:55:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/IntPtr-troubles-with-VB-Net-2005/m-p/863043#M7988</guid>
      <dc:creator>cernek</dc:creator>
      <dc:date>2007-05-14T16:55:18Z</dc:date>
    </item>
  </channel>
</rss>

