[fpc-pascal] C++ > C wrapper callback > Pascal Continues

Tomas Hajny XHajT03 at mbox.vol.cz
Wed Jul 27 15:16:32 CEST 2005

>>> //------------------------------------
>>> PASCAL WRAPPER function being called is below
>>> DllExport void SetL1Callback(TL1Callback p) { DasApi.m_pL1Callback=p;
>>> };
>>> There  seems to be nothing I can find that would cause a Runtime 217 in
>>> the
>>> layout and now finding C conversion of same is working.
>>> Can anyone else please confirm if this should work, or is a bug report
>>> be
>>> in
>>> order??
>> Peter Vreman wrote:
>> A bug report is only in order if there are complete sources otherwise it
>> can't be reproduced.
>>> Thanks to all, whoever may have additional ideas.     Mike
>> Are the pascal units are initialized? A call to FPC_INITIALIZEUNITS is
>> required otherwise the memorymanager etc. will not work.
> Thank you Peter,
>>From the scant references I have found regarding FPC_INITIALIZEUNITS
>> Peter,
> I would think you have the likely cause.  Unfortunately, the 2.0.0. Docs,
> nor the Web docs make reference to the function, (if it is a function),
> and
> Google seems to have only few examples.
> Where can I find documentation on FPC_INITIALIZEUNITS and is it valid in
> fpc-2.0.0, being the docs don't refer it?

Well, maybe I misunderstood the original post, but my understanding was
that it's about a _Pascal_ program calling some C function (which is in
fact just a wrapper for C++, but that shouldn't matter) and passing some
other Pascal function as a callback. If this is the case and the callback
function runs within the same thread as the block calling the C wrapper,
Pascal units should be initialized since the main Pascal program startup,
shouldn't they? If a new thread is started by the C++ program, you need to
perform (Pascal) initialization of the thread (probably on the first entry
to the callback function). Could you clarify this, please (link to the
complete sources or preferrably their simplified but still compilable
version would probably serve the best as already pointed out by Peter)?


More information about the fpc-pascal mailing list