paxCompiler for Delphi. Support of dll-defined functions written in Microsoft Visual Studio C++.


type
  PMyPoint = ^TMyPoint;
  TMyPoint = record
    x, y, z: Integer;
  end;

// int __msfastcall cube(int num); 
function cub(X: Integer): Integer; msfastcall; 
external 'CppDll.dll' name 'cube';

// double __msfastcall arr(double a[], int i, int j, float f);
function arr(A: Pointer; X, Y: Integer; S: Single): Double; msfastcall; 
external 'CppDll.dll';

// Point  __msfastcall ret_struct(int x, int y, int z);
function ret_struct(X, Y, Z: Integer): TMyPoint; msfastcall;
external 'CppDll.dll';

// MyPoint __msfastcall pass_struct(const MyPoint & q);
function pass_struct(P: PMyPoint): TMyPoint; msfastcall;
external 'CppDll.dll';

// char __msfastcall ret_char(char * s)
function ret_char(s: PChar): Char; msfastcall;
external 'CppDll.dll';

var
  p: TMyPoint;
  a: array[0..5] of double;
begin
  a[0] := 5.3;
  a[1] := 10.1;

  writeln(cub(2));
  writeln(arr(@a, 2, 3, 6.8));

  p := ret_struct(2, 3, 5);
  writeln(p.x, ' ', p.y, ' ', p.z);

  p := pass_struct(@p);
  writeln(p.x, ' ', p.y, ' ', p.z);

  writeln(ret_char('abc'));
end.


Copyright © 2006-2017 Alexander Baranovsky. All rights reserved.