1 people like it.

interop 64 bit problem

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
open System
open System.Runtime.InteropServices
open Microsoft.FSharp.NativeInterop

[<System.Runtime.InteropServices.DllImport("pgm_cpp.dll", EntryPoint="add", CallingConvention=CallingConvention.Cdecl)>]
extern void add(nativeint a, nativeint b);
let add2 x y =
    let mutable x1 = nativeint x
    let mutable y1 = nativeint y
    add(x1, y1)

// declaration
// extern "C"  __declspec(dllexport) void add(int a, int b);
// definition
// void add(int a, int b) { printf("Why?"); }
namespace System
namespace System.Runtime
namespace System.Runtime.InteropServices
namespace Microsoft
namespace Microsoft.FSharp
namespace Microsoft.FSharp.NativeInterop
Multiple items
type DllImportAttribute =
  inherit Attribute
  new : dllName:string -> DllImportAttribute
  val EntryPoint : string
  val CharSet : CharSet
  val SetLastError : bool
  val ExactSpelling : bool
  val PreserveSig : bool
  val CallingConvention : CallingConvention
  val BestFitMapping : bool
  val ThrowOnUnmappableChar : bool
  member Value : string

Full name: System.Runtime.InteropServices.DllImportAttribute

--------------------
DllImportAttribute(dllName: string) : unit
Multiple items
type EntryPointAttribute =
  inherit Attribute
  new : unit -> EntryPointAttribute

Full name: Microsoft.FSharp.Core.EntryPointAttribute

--------------------
new : unit -> EntryPointAttribute
type CallingConvention =
  | Winapi = 1
  | Cdecl = 2
  | StdCall = 3
  | ThisCall = 4
  | FastCall = 5

Full name: System.Runtime.InteropServices.CallingConvention
field CallingConvention.Cdecl = 2
val add : a:nativeint * b:nativeint -> unit

Full name: Script.add
Multiple items
val nativeint : value:'T -> nativeint (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.nativeint

--------------------
type nativeint = IntPtr

Full name: Microsoft.FSharp.Core.nativeint
val a : nativeint
val b : nativeint
val add2 : x:int -> y:int -> unit

Full name: Script.add2
val x : int
val y : int
val mutable x1 : nativeint
val mutable y1 : nativeint
Raw view Test code New version

More information

Link:http://fssnip.net/ps
Posted:9 years ago
Author:
Tags: