title: PInvoke: Issue with returned array of doubles?
body: <p>I am using <code>PInvoke</code> to call a C++ function from my C# program. The code looks like this:</p>
  
  <pre><code>IntPtr data = Poll(this.vhtHand);
  double[] arr = new double[NR_FINGERS /* = 5 */ * NR_JOINTS /* = 3*/];
  Marshal.Copy(data, arr, 0, arr.Length);
  </code></pre>
  
  <p>With <code>Poll()</code>'s signature looking like this:</p>
  
  <pre><code>[DllImport("VirtualHandBridge.dll")]
  static public extern IntPtr Poll(IntPtr hand);
  </code></pre>
  
  <p>The C-function <code>Poll</code>'s signature:</p>
  
  <pre><code>extern "C" __declspec(dllexport) double* Poll(CyberHand::Hand* hand)
  </code></pre>
  
  <p>Unless I'm having a huge brain failure (admittedly, fairly common for me), this looks to me like it should be working.</p>
  
  <p>However, the double values I am getting are completely incorrect, and I think this is because of incorrect memory usage. I have looked it up, and I think doubles in C# and C++ are identical in size, but maybe there is some other issue playing here. One thing that rubs me the wrong way is that <code>Marshal.Copy</code> is never told what type of data it should expect, but I read that it is supposed to be used this way.</p>
  
  <p>Any clues, anyone? If needed, I can post the correct results and the returned results.</p>