[fpc-devel] Access Violation with nested DLL's compiled by FPC(and some more info on bug #4538)
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Sun Dec 11 01:41:46 CET 2005
On 12/10/05, Stefan van den Berg <chtk at xs4all.nl> wrote:
> The usage of strings in the samples was just to verify which code was
> executed and where things went wrong. I wasen't aware of the fact that
> that alone could cause problems. In the actual application mainly
> objects are passed to functions as regular and out parameters and a
> boolean is returned to indicate success or failure.
If you open Delphi 5, and say you want to create a dll it will create
a file with about three keywords (library, exports, uses) and then a
HUGE notice:
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
So never, ever user Ansistrings on DLLs unless you have a shared memory manager.
If you must use strings just use shortstring. If you need longer
strings you can use PChar.
--
Felipe Monteiro de Carvalho
More information about the fpc-devel
mailing list