[fpc-pascal] fpc 2.3.1 doesn't allow to pass literal constants as formal const parameter

Vincent Snijders vsnijders at quicknet.nl
Thu Mar 6 22:22:33 CET 2008


Peter Vreman schreef:
>> Currently fpc 2.3.1 cannot build lazarus anymore. It fails on lines like
>> MyStream.Write(' ',1);
>>
>> The write method is declared as
>>    function Write(const Buffer; Count: Longint): Longint
>>
>> Why isn't passing literal constant to a formal const parameter allowed
>> anymore?
> 

I see this change is intentional, but I don't understand it completely yet.

> 1. It is passed by value and not by reference.

The compile could decide to pass by reference, couldn't it.

> 2. You don't know the size of the value.

The caller knows the size, doesn't it. Why do you need to know the size?

> 3. It is delphi compatible
> 

At last, one reason I understand :-).

Thanks,
Vincent



More information about the fpc-pascal mailing list