...
Dec(Var I : Longint;decrement : Longint); Dec(Var I : Longint); Dec(Var I : Byte;decrement : Longint); Dec(Var I : Byte); ... |
When the compiler encounters a call to the dec function, it will first search which function it should use. It therefore checks the parameters in a function call, and looks if there is a function definition which matches the specified parameter list. If the compiler finds such a function, a call is inserted to that function. If no such function is found, a compiler error is generated. functions that have a cdecl modifier cannot be overloaded. (Technically, because this modifier prevents the mangling of the function name by the compiler).
Prior to version 1.9 of the compiler, the overloaded functions needed to be in the same unit. Now the compiler will continue searching in other units if it doesn’t find a matching version of an overloaded function in one unit.
The compiler accepts the presence of the overload modifier as in Delphi, but it is not required, unless in Delphi mode.