[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling C from T in the Apollos ?



    Why can't we call C functions from T ?. The defapollo package
    seems to work only with Pascal routines. The strange thing is
    that you can call C from Pascal and viceversa, so somehow C and
    Pascal are "compatible".  However, when you try to call C from
    T, it won't work.

    Would it work if I write a dummy Pascal function that just calls
    the C function, using Pascal as an interface between T and C ?
    
Well, first of all, C calling Pascal is the only really "easy" case.
The C calling convention is different from the Pascal calling
convention.  However, Apollo C has the "apollo_$std" C feature to
declare external Pascal procedures to C modules.  The C compiler
generates a Pascal-style call to procedures declared "apollo_$std".

You can call C from Pascal, but you have to remember since Pascal
is call-by-reference, you have to deal with an extra layer of
indirection in the C code.

As for T calling C, your suggestion will clearly work.  

I haven't tried it, but I can't see why calling C directly from T
should be a problem as long as you understand that on the C side,
it looks like the Pascal-calls-C case described above.  One problem
with DEFINE-APOLLO for interfacing to C procedures is that you can't
use the STRING feature since it causes a string pointer and a length
to be passed (since virtually all Apollo Pascal procedures that take
strings also take lengths).

                -- Nat