Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-07

C++ > C wrapper callback > Pascal Continues

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Urbansound
Show quoted text 24 lines
> //------------------------------------ > 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

Peter Vreman
to Urbansound
Show quoted text 38 lines
>> //------------------------------------ >> 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.

Tomas Hajny
to Urbansound: I would think you have the likely cause. Unfortunately, the 2.0.0. Docs, nor the Web…
Show quoted text 38 lines
>> //------------------------------------ >> 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