Markus Gerwinski wrote:
Frank Heckenbach wrote:
Please look at gpc-in-c.h, as there may be more things you'll have to do. (You can ignore the part about `--gpc-main' if you only have units on the Pascal side.)
Okay, thanks. Calling _p_initialize solves the problem, of course. However, since it wasn't necessary in an earlier version, I wonder what has changed since?
When was it not necessary? gpc-in-c.h has existed for quite some time. If this particular case didn't crash before didn't mean that initialization wasn't necessary.
Pure Pascal projects are not affected, there the RuntimeError just works fine.
More precisely, if the main program is in Pascal, things are initialized/finalized automatically. So unless the C part insists on providing main(), you might consider this alternative. (You can then, of course, call a big C function which does most of the work from the Pascal main program, and the C functions can then call back to Pascal anytime.)
Problem is, what I'm writing here is a library, so most probably there will be some users who insist on running it from a C main(). However, I could just provide all of my C demo programs with init()- and fini()-calls at the beginning and the end; that should be clear enough.
Yes, you might want to wrap them in library-init/fini routines, particularly if you need to do other initialization/finalization yourself.
If several such libraries are used together (or one such library with a Pascal main program), RTS initialization/finalization is done several times, but at a guick glance (you might want to check for yourself), I think they are idempotent, so no problem.
Frank