[fpc-devel]cdecl directive & fpc-devel archives...
Marco van de Voort
Marcov at stack.nl
Sun Oct 29 14:09:31 CET 2000
> Anyway, what about my question regarding the implementation in other
> compilers (I mean mostly TPW and Delphi here)?
I think this is less relevant. Both TPW and Delphi had the luxury
that the C compilers they linked to were made by the same
company, so they could adapt both sides to keep things
interchangable.
We have to keep the linking possibility to gcc at any cost, since
without it, the value of having Linux and FreeBSD platforms
decimates. But on the other hand we also have to keep linkability
to several Win32 C compilers and Delphi because of the DLL's.
Personally I think that if we should make fundamental changes to
the external linking stuff, it would have to be a fundamental
reconsideration of declaring calling conventions and external.
A good example would be to consider the TopSpeed way. The
TopSpeed range of compilers (which I used before FPC) allowed full
configuration of callingconventions for each individual procedure
with directives like this: (only schematic, don't have TS here atm)
{#pragma cconv=>pascal,reg=>ax,dx,cx,freg=st(0),st(1)}
Which means something like:
- Pascal order of pushing parameters, opposed to C
- Register parameters, first param in ax, second in dx, third in cx
(parameters bigger than wordsize are put on the stack), floating
point values on the copro stack, but no more than two values in 0
and 1).
Reg=>' ' meant no reg parameters IIRC.
If we then also allow to redefine external, cdecl and their mangling
with such directives, we could get much more control over external
linking, and support a lot more compilers in a systematic way,
without too much different modi, directives and all together if
necessary. (like linking to cygwin static libs, while in a different unit
linking to Delphi DLLs etc)
It probably is something for the new cg (since it would be wise to
do it together with the reg parameters possibility to avoid double
work).
In that case for all processors a list with the prefered order for
registerparameters should be used, so that the definition would be
more or less processor independant.
Some much used settings (like gcc and the diffent conventions of
delphi) could be predefined, and also different compiler modes
could have different defaults.
More information about the fpc-devel
mailing list