Frank Heckenbach frank@fjf.gnu.de wrote:
[...]
Delphi has the same notation, with the same syntax as above, used in the context of *importing* routines from dynamic link libraries (DLLs). Normally the DLL's name will be in-between "external" and "name" -e.g.,
Procedure FooBar; external 'barfoo.dll' name 'FooBar';
I think we could do the same, with the 'barfoo.dll' being optional (is it optional in Delphi as well?). If it's omitted, the compiler will assume the library or object file which contains the routine to be linked by other means (e.g., other `external' statements, `{$L barfoo}' directives, or on the command line).
Yes, that is more or less what Delphi does as well.
Furthermore, I think we should drop the `.dll', i.e. just have external 'barfoo', to link `barfoo.dll' on Win32, and `barfoo.so' on Unix, or `barfoo.a' on any system. IOW, it's equivalent to `{$L barfoo}'. Also, we should allow "external 'foo.o'" to link an object file,', "external 'foo.c'" for C files etc. (which is also completely equivalent to the `{$L}' directive).
Sounds mostly okay - except that with Win32, a DLL does not need to have the extension '.dll' (for example, Win32 device drivers are just DLLs with the same interface, and with the extension '.drv' ). A Win32 DLL can have any extension, or no extension at all. Thus it might be that the extension will need to be specified. On the other hand, I suppose that perhaps GPC can presume the extension '.dll' unless another extension is suppled. However, how do you then deal with a case where someone has written a DLL but does not want to give it any extension?
[Libraries]
The problem I see with the syntax above is that the external name declaration is at the end. I doubt whether GPC can could with that well since AFAIK it expects to know the external name when it compiles a routine. Perhaps it could use a temporary name while compiling the routine, and declare the real external name as an alias of that temporary name later, but I'm not too sure if that's possible.
If that's not possible, then perhaps a GPC library could look somewhat like a unit, i.e.
library foo;
interface
procedure foobar; name 'FooBar';
implementation
procedure foobar; begin end;
end.
This would not be so much different from what we have already, and therefore probably be easier to realize.
That sounds like a reasonable compromise. This will not be BP or Delphi-compatible, but it is arguably more consistent to do it this way, and this will also make it trivial to convert a UNIT into a library (something that is not so straightforward with Delphi).
Best regards, The Chief -------- Dr. Abimbola A. Olowofoyeku (The African Chief) Email: laa12@keele.ac.uk Homepage: http://ourworld.compuserve.com/homepages/African_Chief/ Author of: Chief's Installer Pro v5.00 for Win32 ftp://ftp.simtel.net/pub/simtelnet/win95/install/chief500.zip