I have a C function I'm exposing to F# code:
#define EXPORT extern "C" __declspec(dllexport)
EXPORT Video *NewVideoEncoder(LPCWSTR file, unsigned int width, unsigned int height)
The client F# code is:
module VideoFunctions =
open System
open System.Runtime.InteropServices
[<DllImport(Common.LibraryName)>]
extern IntPtr NewVideoEncoder(IntPtr filename, uint32 width, uint32 height)
let strPtr = Marshal.StringToHGlobalUni(filename)
let video = VideoFunctions.NewVideoEncoder(strPtr, uint32 width, uint32 height)
When I can the code I get a "Managed Debugging Assistant 'PInvokeStackImbalance'" warning. The code appears to execute correctly, but I observe some weird behaviour with later PInvoke calls.
The docs say the most likely cause of this is a signature mismatch, but to me two signatures look identical.