Adriaan van Os wrote:
Markus Gerwinski wrote:
I attached some test code to this mail that reproduces a bug in GPC that just occurred in one of my projects. In short: When I link a Pascal unit to a C project, and a function in the Pascal unit calls RuntimeError, this results in a segfault when called from within the C code. (I'm using gpc-20050331 together with gcc-3.4.3.)
I think the problem is that the Pascal runtime is not initialized (see the thread "Default linker names").
Yes, seems so.
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.)
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.)
Frank