Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'cdecl = nil' (placed after a function declaration) mean?

Tags:

delphi

Check this demo source from the excellent Detour library:

implementation

{$R *.dfm}

var
  TrampolineGetMemory: function(Size: NativeInt): Pointer;
cdecl = nil;

Please look at the cdecl = nil; statement. What does it mean in this context?

Note - I already know that cdecl stands for a calling convention.

like image 857
Edwin Yip Avatar asked Apr 19 '16 13:04

Edwin Yip


1 Answers

This is just another way to initialize the variable. For example:

program Project1;

{$APPTYPE CONSOLE}

var
  i : integer = 5;
begin
  WriteLn(i);
  ReadLn;
end.

it may be clearer if it was written on one line as

var
  TrampolineGetMemory: function(Size: NativeInt): Pointer; cdecl = nil;

Or maybe even better if a type was defined :

type
  TTrampolineGetMemory = function(Size: NativeInt): Pointer; cdecl;

//... 
 var
   TrampolineGetMemory: TTrampolineGetMemory = nil;
like image 189
J... Avatar answered Sep 30 '22 19:09

J...