The compiler can't generate those names automatically for you, because it exports in a
C compatible way, not
C++. C functions are not mangled like this.
You can force a specific name by using the
name clause in the
exports section:
exports
SubStr name '_SubStr@12';
However you'll have to calculate that mangled name manually.
If you want to use Pascal functions in a C++ program you should import them as
extern "C" instead:
extern "C" __declspec(dllimport) int __stdcall SubStr(char* CString, int frompos, int topos);
In both cases you'll need to generate an import library. In theory FPC is able to generate a *.def file that you can then use the Microsoft tools to generate an import library of, but that seems to be buggy currently.
Thus you'll need to manually create an import library:
For the C case:
LIBRARY MyLib
EXPORTS
SubStr
For the C++ case:
LIBRARY MyLib
EXPORTS
_SubStr@12
And then create an import library from that (not tested):
lib.exe -machine:IX86 -def:mylib.def -out:mylib.lib
Please note that this is only for Windows (and OS/2 and DOS). For *nix systems that topic is different again.