[fpc-devel] calling DLL imports

Yury Sidorov jura at cp-lab.com
Wed May 10 22:12:24 CEST 2006


Hello,

I noticed the following issue:

Example code:

//-------------
program MyProg;

procedure TestProc(Text: PWideChar); external 'test.dll';

begin
  TestProc('qwerty');
end.
//-------------

When compiling for win32, TestProc is called by normal name:
call    TestProc

When compiling for arm-wince, TestProc is called by mangled name:
bl      P$MYPROG_TESTPROC$PWIDECHAR

Why the name is different?

Both cases are not good.

In the first case there will be duplicate name confilct when function with
the same name will be imported from different dlls in different units.

In the second case import section will not be reused if the same function is
imported in several units. Several different import sections will be created
for each import, but single section can be used instead.

Is it possible to generate different mangled name for imported functions?

Like this:
P$MYPROG_TEST_DLL_TESTPROC$PWIDECHAR

It will solve both issues.

Yury Sidorov.




More information about the fpc-devel mailing list