blob: 1b5de483e2178ac76c3bd6e9019332a880c6e319 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
{ %fail }
{ %CPU=i386 }
{ %target=windows,linux }
{ Target must have distinct stdcall and cdecl calling conventions, otherwise this test will (wrongly) succeed }
{$mode objfpc}{$H+}
{$MACRO ON}
uses
Classes;
type
// Declare wrong calling convention
{$ifdef WINDOWS}
{$DEFINE extdecl := cdecl}
{$else}
{$DEFINE extdecl := stdcall}
{$endif}
{ TObj }
TObj = class(TInterfacedObject, IUnknown)
function IUnknown._AddRef = AddRef; // This must produce a error because of calling convention mismatch.
function AddRef : longint;extdecl;
end;
{ TObj }
function TObj.AddRef: longint;extdecl;
begin
WriteLn('TObj.AddRef call');
inherited;
end;
var O:TObj;
begin
O:=TObj.Create;
(O as IUnknown)._AddRef;
O.Free;
end.
|