[fpc-pascal] constant records as default parameters

David Emerson dle3ab at angelbase.com
Thu Dec 30 20:40:33 CET 2010

I'd like to use a constant record as a default parameter. Is there some way to 
do this? Here's my use case:

  lt_ints = record
    left, top : longint;

  lt_zero : lt_ints = (left:0; top:0);

procedure do_something (const offset_lt : lt_ints = lt_zero);

The procedure declaration gives an error ("illegal expression").

I assume the trouble is that lt_zero cannot be used as a default parameter 
value, because it is not truly a constant: it is an initialized variable.

Perhaps my real question is: how do I make a constant record which is truly 
constant, rather than an initialized variable?


Thanks :-)

More information about the fpc-pascal mailing list