我正试图从F#调用一个C库,并遇到了一个奇怪的问题.我有一个包含我所有extern功能的模块.底层C库有两个具有相同名称但不同参数的函数.当然,这在F#模块中是不允许的.
module C =
open System.Runtime.InteropServices
[<DllImport("libc", CallingConvention = CallingConvention.Cdecl)>]
extern int setValue(nativeint source, int value)
[<DllImport("libc", CallingConvention = CallingConvention.Cdecl)>]
extern int setValue(nativeint source, string value)
// the previous function declaration cause the following compile-time error:
// Duplicate definition of value 'setValue'
Run Code Online (Sandbox Code Playgroud)
有什么特殊的方法可以解决这个问题吗?我无法改变C库.