Hello, Pascal folks,
I'm using FPC 2.0.4 on MacOSX 1.4.9 PPC and trying to write a Pascal library
that is externally called from REALbasic (Rb). But Rb needs Carbon.h header
included in dylibs which are called by Rb programs.
In C, it's easy:
#include "Carbon/Carbon.h"
Unfortunately, I am not familier to C, so that, I want to write the library
in FPC. How it can be achieved in FPC?
Could you give me some suggestions?
I have used CarbonEventsCore.ppu, but found not sufficient enough. The
application still crashes in certain circumstances.
So the Pascal code compiles, links with the RB code, but crashes when it
runs? How far does it run?
It can't possibly be a problem with calling conventions? Pascal routines
that you need to call from C need to be declared appropriately, with
"cdecl" or "MWPascal" (which are equivalent, I think). Could that be the
problem? Then Jonas' suggestion to use "{$calling mwpascal}" could be
just what you need. Then your calls will be compiled to use C calling
conventions.
Another problem when mixing languages is the Pascal RTL. You might need
to link with that. (That is not necessarily trivial, I am having trouble
with that myself.) But that doesn't sound like your problem, right?
/Ingemar
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal