C++ > C wrapper callback > Pascal Continues

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

C++ > C wrapper callback > Pascal Continues

Urbansound


>> //------------------------------------
>> PASCAL WRAPPER function being called is below
>>
>> DllExport void SetL1Callback(TL1Callback p) { DasApi.m_pL1Callback=p; };
>>
>> SUMMARY:
>> 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?

Regards,
Mike


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: C++ > C wrapper callback > Pascal Continues

Peter Vreman
>>> //------------------------------------
>>> PASCAL WRAPPER function being called is below
>>>
>>> DllExport void SetL1Callback(TL1Callback p) { DasApi.m_pL1Callback=p;
>>> };
>>>
>>> SUMMARY:
>>> 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?

It is an internal function implicitly called by the compiler. It is not
for use by normal users and therefor not in the docs. It also requires a
table with the units to initialize. For a program and library this table
is inserted. If you link a single .o file it will not work.




_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: C++ > C wrapper callback > Pascal Continues

Tomas Hajny
In reply to this post by Urbansound
>>> //------------------------------------
>>> PASCAL WRAPPER function being called is below
>>>
>>> DllExport void SetL1Callback(TL1Callback p) { DasApi.m_pL1Callback=p;
>>> };
>>>
>>> SUMMARY:
>>> 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)?

Tomas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal