[fpc-devel]I suggest a new FPC feature

Pierre Muller pierre at freepascal.org
Fri Oct 12 10:02:44 CEST 2001


>type
>t1=class
>  procedure test;cdecl;virtual;
>end;
>t2=class(t1)
>  procedure test;cdecl;override;
>end;
>procedure t1.test;cdecl;
>  begin
>  end;
>procedure t2.test;cdecl;
>  begin
>  end;
>begin
>end.
>(test3.pp(10,2) Error: Asm: Duplicate label _test)

   This is because cdecl is not only a calling convention,
in the sense that it specifies how parameters are sent to the program
and how these are disposed, but also a naming convention.
  A cdecl'ed function
function Cname : longint;
get a '_Cname' assembler label or ('Cname' for ELF unixes).

  You can now easily see why the override makes a problem...

   Partial solve would be to add the class name, but
anyhow this will have nothing to do with the C++ way of giving internal
names to methods.

   Thus I would simply suggest to refuse cdecl for method,
popstack would still be accepted and has the same effect as
cdecl for the calling convention.

   I just have one point where I am not sure that popstack and
cdecl conventions agree, it is the case of complex (for instance records)
return values.

    C code for i386 uses ret $4 in such cases,
but popstack might not do so...


  




More information about the fpc-devel mailing list