While trying to call function with following signature (compiled by MSVC++):
BOOL CreateJunctionPoint(LPCTSTR szMountDir, LPCTSTR szDestDir);
and described in F# as
[<DllImport("FSLinks.dll", CallingConvention = CallingConvention.Cdecl)>]
extern int CreateJunctionPoint(string source, string target)
I get stack imbalance.
The same function called from C# works perfectly.
After changing calling convention to stdcall in C++:
BOOL __stdcall CreateJunctionPoint(LPCTSTR szMountDir, LPCTSTR szDestDir);
F# program begin working normally (though still having CallingConvention = CallingConvention.Cdecl set) Seems like obvious compiler bug to me.
Both compilers are from Visual Studio 2010 (Microsoft (R) F# 2.0 Compiler build 4.0.30319.1)
Yes, this is a known bug.