14.4.7 Untyped parameters

Variable, Out and constant parameters can be untyped. In that case the variable has no type in the procedure of function, and hence is incompatible with all other types: The compiler simply passes the address of the passed variable to the routine, so all that is available in the called routine is an address, with no type information attached to it. This is also true for const parameters.

Using an analogy

procedure Something(const Data; Len: cint);

Is equivalent to the following C/C++ declaration:

void Something(void* Data; int Len);

This means pretty much all that one can do in the routine is use the address operator or pass the argument to another function that has also an untyped parameter.

Inside a routine with an untyped parameter, if the untyped parameter is used in an expression, or a value must be assigned to it a typecast must always be used.

The following example shows this:

{$mode objfpc}  
uses types;  
procedure doit(const d);  
  Writeln(’As integer: ’,PInteger(@D)^);  
  Writeln(’As Byte   : ’,PByte(@D)^);  
  D : Integer;  

This will write:

As integer: 268435440  
As Byte   : 240

Note that because an address is needed, no constant expressions can be passed to the function or procedure, i. e. given the above definition, the following will not work:


This will result in the following error:

Error: Variable identifier expected