title: Calling convention in C++/CLI
body: <p>I've defined a function for a C++/CLI library:</p>
  
  <pre><code>extern "C"
  {
      INT_PTR __cdecl brl_graphics_Graphics(int Width, int Height, int Depth, int Hertz, int Flags);
  }
  </code></pre>
  
  <p>And this is the function that calls it, it's just a wrapper:</p>
  
  <pre><code>IntPtr BlitzMax::BlitzMax::Graphics(int Width, int Height, int Depth, int Hertz, int Flags)
  {
      return IntPtr(brl_graphics_Graphics(Width, Height, Depth, Hertz, Flags));
  }
  </code></pre>
  
  <p>When I call it from a C# application I get a AccessViolationException, for some reason in the disassembly it doesn't use cdecl calling convention:</p>
  
  <pre><code>push        dword ptr [ebp+10h] 
  push        dword ptr [ebp+0Ch] 
  push        dword ptr [ebp+8] 
  mov         ecx,dword ptr [ebp-4] 
  mov         edx,dword ptr [ebp-8] 
  call        FFD595B8
  </code></pre>