Waldek Hebisch wrote:
Frank Heckenbach wrote:
As another small step towards cleaning up the `external' mess in GPC, I'm now implementing `external name', i.e.
procedure Foo; external name 'bar';
will be equivalent to
procedure Foo; external; asmname 'bar';
I think that external should indicate language -- C may is good as default, but incompatible name mangling schemes profilerate. Currentely Pascal, Fortran, C++ and Ada in GCC all use different schemes (and with a.out assembler <> C).
Are you referring to the prepended underscore in DJGPP (using COFF)? AFAIK, that's just for compatibility with other Dos C compilers which use Intel asm syntax where an identifier such as `ax' (which is valid in C, of course) would conflict with a processor register. So, I think for all higher languages, the underscore is "invisible" (i.e., when interfacing between C and Pascal, you don't have to worry about it), only those who write interfacing asm code have to add it explicitly.
It seems much better to avoid users doing mangling by hand. And even if support for other languages is delayed it is better to reserve the syntax in advance.
Well, which syntax? The existing and suggested syntax only covers explicitly specified asmnames (which should always be possible, of course).
So if we want to support other language's mangling schemes in the future (which is probably more than one can of worms, and I'm not sure if will be feasible, given that even different C++ compilers use different schemes), we need some additional syntax.
A new `attribute' can always be added (no danger of conflicts).
If you're thinking of something like `external 'C' ...' (similar to `extern "C"' in C++), there might be conflicts since BP actually allows (which GPC doesn't support yet, but might in the future):
external 'library-name' name 'asmname';
So, which syntax do you propose?
BTW, I do not think one should emulate other language's mangling manually, either. But it also works if all languages allow you to specify an explicit linker name for the interface routines -- in C that's trivial (no mangling at all), in GPC that's `asmname' (subject to the proposed changes), in C++ it's `extern "C"' (not for objects, though, but the incompatibilities between C++ and GPC objects are much deeper than the name mangling, anyway). I don't know enough Fortran or Ada to tell if there are such mechanisms ...
Frank