creating dll to link with delphi program
Tobias Burnus
burnus@net-b.de
Mon Oct 24 14:16:00 GMT 2011
Brad Finney wrote:
> Yes, I did try his suggestion, but missed the addition of the bind(c,
> name= " ").
Well, that was the most important part ...
> Thanks for getting me to read more carefully! That does correct the
> case issue, but not (for me) the underscore issue, which is very
> puzzling. I took the exact code you listed and got a leading
> underscore on Foo and bar.
>
> F:\FlowReader>nm foo.o
> 00000000 T _Foo
The leading _ is added there because the ABI (application binary
interface) of 32bit Windows *requires* it. If you don't like it, blame
Microsoft.
Are you sure that you do not need the leading underscore? I do not want
to rule out that Delphi is broken, but the 32bit Windows ABI makes
pretty clear that Windows should have a leading underscore, see:
http://msdn.microsoft.com/en-us/library/zkwh89ks%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/zxk0tw93%28v=VS.71%29.aspx
Thus, I think your problem should be elsewhere. Can you check what
Delphi actually wants? Does it use STDCALL or CDECL? How does it call
Windows functions - which all start with a leading underscore?
Regarding CDECL/STDCALL: With CDECL (default in GCC), the caller puts
the procedure arguments on the the stack, calls the procedure and then
pops it from the stack. With STDCALL, the caller puts the actual
arguments on the stack and calls the procedure - but here the called
procedure pops the stack. STDCALL is the widely used by (32bit)
Microsoft's DLL - but not by all of their libraries. - It might be that
Delphi on Windows uses STDCALL by default - but it could also use
STDCALL (or in principle also FASTCALL). For those, see the two MS links
above and
http://gcc.gnu.org/onlinedocs/gfortran/Mixed_002dLanguage-Programming.html
Tobias
More information about the Fortran
mailing list