我注意到,如果我用StructLayout.Sequential定义一个结构,如下所示:
open System.Runtime.InteropServices
[<StructLayout(LayoutKind.Sequential, Pack=1)>]
type SomeType =
val mutable Field1: uint32
val mutable Field2: uint32这在实际程序中编译和工作得很好,但FSI给出了错误error FS0193: internal error: Could not load type 'SomeType' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because field 'Field1' was not given an explicit offset.
这是FSI的缺陷还是限制?有解决办法吗?
发布于 2014-07-06 01:20:29
解决方法(错误有提示):
[<Struct;StructLayout(LayoutKind.Explicit)>]
type SomeType =
[<FieldOffset(0)>]
val mutable Field1: uint32
[<FieldOffset(4)>]
val mutable Field2: uint32https://stackoverflow.com/questions/24587684
复制相似问题