[fpc-pascal] declaration of functions
Sven Barth
pascaldragon at googlemail.com
Fri Oct 15 11:21:23 CEST 2010
Am 15.10.2010 11:13, schrieb Jonas Maebe:
>
> On 15 Oct 2010, at 11:07, Sven Barth wrote:
>
>> Am 14.10.2010 14:50, schrieb Uffe Kousgaard:
>>> interface
>>> function somefunction(a: integer): integer;
>>>
>>> implementation
>>> function somefunction;
>>> begin
>>> result:= a*2;
>>> end;
>>
>> Add
>>
>> {$mode delphi}
>>
>> at the top of your unit, then this "Delhpi compatible" syntax will be
>> enabled. The two default FPC modes (fpc and objfpc) are more strict
>> than the Delphi one.
>
> As an aside, this has nothing to do with strictness. The reason is that
> FPC and ObjFPC mode allow function overloading without the "overload"
> keyword. So the compiler sees the above as two overloaded functions (one
> public, one private) as opposed to the interface and implementation
> declaration of the same function.
Do you have to destroy my dream? :P
But you can see it as an indirect strictness. Because FPC sees a
declaration with and one without parameters as two functions you can't
omit the parameter declaration.
Btw: If I remember correctly, I need to repeat calling conventions as
well in the FPC modes... so does the compiler treat to similar functions
with two different calling conventions as overloaded?
E.g.
procedure Foo(Bar: Integer); stdcall;
procedure Foo(Bar: Integer); cdecl;
Is this possible?
If so: what's the use of this? I can't differentiate the procedures by
calling convention when I call them...
If it is not so: why do I need to repeat the calling convention then
(only if I remembered this correctly, of course)?
Regards,
Sven
More information about the fpc-pascal
mailing list