需要将C#代码移植到F#:
[DllImport("libc", SetLastError = true)]
private static extern int chmod(string pathname, int mode);
以下代码有什么问题?在Mac上的FSI中尝试并获得error FS0193: internal error: Method 'FSI_0020+Libc.chmod' does not have a method body.
module Libc =
open System.Runtime.InteropServices
[<DllImport("libc", SetLastError = true)>]
extern int chmod(string pathname, int mode)
[<DllImport ("libc", EntryPoint = "chmod", SetLastError = true)>]
extern int sys_chmod (string _path, uint32 _mode)
let chmodCarry mode path = sys_chmod(path, mode)
在这种情况下如何处理private
和static
?我会使sys_chmod变为私有并仅公开携带的chmod
函数。
或者还有其他更便携的方法来使文件可执行吗?