Can't link to external DLL symbol with '?' in the name
Original Reporter info from Mantis: michi_cc
-
Reporter name: Michael Lutz
Original Reporter info from Mantis: michi_cc
- Reporter name: Michael Lutz
Description:
Linking to an external symbol in a DLL can fail if the external name contains a '?' character. The failure occurs if the external procedure is declared in the interface section of a unit while the "external '' name '?'" statement is in the implementation section. It works if those two conditions aren't met.
Summary:
* "external 'a' name 'b" works everywhere
* "external 'a' name '?b" works sometimes:
- "external ..." in the main program file works
- "external ..." in the interface section of a unit works
- "external ..." in the implementation of a unit if the procedure is not declared in the interface section works
- 'external ...' in the implementation of a unit together with a declaration in the interface section does NOT work
Steps to reproduce:
$ cat test2.pas
program Test2;
uses TestUnit;
begin
Dummy;
end.
$ cat testunit.pas
unit TestUnit;
interface
procedure Dummy;
implementation
procedure Dummy; external 'who_cares' name '?Dummy';
end.
$ fpc test2.pas
Free Pascal Compiler version 2.4.4 [2011/09/29] for x86_64
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Win64 for x64
Compiling test2.pas
Compiling testunit.pas
Linking test2.exe
test2.pas(7,1) Error: Undefined symbol: ?Dummy
test2.pas(7,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Additional information:
http://lists.freepascal.org/lists/fpc-pascal/2011-October/030373.html
Mantis conversion info:
- Mantis ID: 20456
- OS: Windows
- OS Build: 7
- Platform: x86_64-win64
- Version: 2.4.4
- Fixed in version: 3.0.0
- Fixed in revision: 28035 (#4b5736a3)
- Monitored by: » michi_cc (Michael Lutz)