[fpc-pascal] Underscore prefix for external C functions
Adriaan van Os
fpc at microbizz.nl
Fri Sep 7 14:31:40 CEST 2007
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.
> The universal interfaces are declared as mwpascal rather than cdecl, and
> such functions/procedures do not automatically get the C-prefix
> (although one might argue that it would have been better if they did,
> and indeed if FPC on all platforms by default prefixed all its symbol
> names with the same prefix as the main C compiler(s), but the fact is
> that it doesn't do so today -- but maybe this could be changed now that
> there still aren't many FPC shared libraries in common use).
Yes.
> 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 ?
Regards,
Adriaan van Os
More information about the fpc-pascal
mailing list