我正在尝试从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'
有没有什么特别的方法来解决这个问题?我不能修改C库。