C++ > C wrapper callback > Pascal Continues

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

C++ > C wrapper callback > Pascal Continues

Urbansound

Reply Peter and Tomas, is below, each... Thread pruned.

>   2. Re:  C++ > C wrapper callback > Pascal  Continues (Peter Vreman)
>   3. Re:  C++ > C wrapper callback > Pascal  Continues (Tomas Hajny)

> ----------------------------------------------------------------------
> Message: 2
> Date: Wed, 27 Jul 2005 14:26:57 +0200 (CEST)

> It is an internal function implicitly called by the compiler.

The s call in the message line was converted to a "pointer(s)".  I found the
FPC_INITIALIZEUNITS at Main, in the ASM output and understand now that the
compiler handles this fully and that FPC_INITIALIZEUNITS could not be the
issue.  Perhaps this thread will help others new to FPC to know this too on
the chance they may research it.  Thank you.  Present code is at bottom to
thin down the thread.

Tomas below, may be onto it, as a threading issue.  Thanks still for your
help.  Mike

>
> 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

Thanks Tomas.

1) Current function is below, due to pruning the thread.
1) Clearly I was off course on FPC_INITIALIZEUNITS
2) You're understanding is correct C++api > C+wrpr > Pascal as callback
     The wrapper is actually C code in a .cpp, for functionality
3) The API is multi-threaded, having dl'd a thread monitor, showing as many
as 5 threads spawened to the API and accompanied executable.  As well, a
call back occurs by default from the API, at runtime, suggesting it fires
off a single dummy callback event.
4) Can you suggest an approach on the Pasacl Initialization to the thread
and/or some of the areas I should be looking up toward doing the work?
Google is my friend. ;-)

Thank you again.   Mike

//------- Current function model below here

function L1_Callback(quote : pointer) : integer; stdcall; export;
var
    bid_price : single = 0.0;
    s : ansistring = '';
begin
    SendMessage(listbox, LB_ADDSTRING, 0, longint(Pchar('L1 Callback')));
        // -- either commented below will cause crash
    //SendMessage(listbox, LB_ADDSTRING, 0, longint(Get_secsym(quote)));
    //bid_price := Get_l1_BidPrice(quote);
    s := FloatToStr(bid_price);
    SendMessage(ListBox,LB_ADDSTRING,0,Longint(pointer(s)))
end;


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