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

Check out this demo source from the excellent Detour library:

implementation {$R *.dfm} var TrampolineGetMemory: function(Size: NativeInt): Pointer; cdecl = nil; 

See the instruction cdecl = nil; . What does this mean in this context?

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

+5
source share
2 answers

This is another way to initialize a variable. For instance:

 program Project1; {$APPTYPE CONSOLE} var i : integer = 5; begin WriteLn(i); ReadLn; end. 

it might be clearer if it was written on the same line as

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

Or maybe even better if the type was defined:

 type TTrampolineGetMemory = function(Size: NativeInt): Pointer; cdecl; //... var TrampolineGetMemory: TTrampolineGetMemory = nil; 
+7
source

TrampolineGetMemory is a procedural variable initialized by nil .

It’s easier to see if it’s corresponded

 type TTrampolineGetMemory = function(Size: NativeInt): Pointer; cdecl; var TrampolineGetMemory: TTrampolineGetMemory = nil; 
+7
source

Source: https://habr.com/ru/post/1247434/


All Articles