On 07 Sep 2007, at 14:31, Adriaan van Os wrote:
Jonas Maebe wrote:
Is this just a mess or do I miss the true logic behind it ?
If you declare an external function/procedure as "cdecl", the
compiler with /always/ add the necessary C-prefix (if any) to the
external name.
I see, so if I add
{$ifdef FPC}
{$calling cdecl}
{$endif
and skip the underscore, this results in multi-platform and gpc
compatible 'external name xxx" directives.
Yes (save for possibly const-related differences in parameter passing).
To make matters even more interesting (in the Chinese sense),
there are also {$mode macpas} interface-only units (i.e., units
without an implementation section, like many of the universal
interfaces). Because this support was added solely for the purpose
of supporting (older versions of) the universal interfaces, in
that case any function without an explicitly specified external
name also gets the C-prefix added (which does not apply to the
universal interfaces units, since all functions/procedures there
do have an explicitly specified external name).
Are you saying that adding IMPLEMENTATION BEGIN changes the meaning
of the INTERFACE section. That is hardly a defendable compiler
feature, is it ?
Interface-only unit support was (and still is) only a quick hack
added for allowing to compile the universal interfaces. There was
(and still is) no other way to specify both a non-cdecl/cppdecl
calling convention and get automatic addition of C-prefixes. It does
the job for which it was introduced, and was never intended for any
other use than easy porting of legacy interfaces to external (C)
libraries.
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal