Frank Heckenbach wrote:
of accessing RTS internals. One way would be to skip setting arguments if NULL (AFAIK, this can never happen in the main program).
For the environment, it's a bit more difficult, as there are two ways to get it -- the 3rd parameter to `main' and the `[__]environ' variable. The latter is POSIX, AFAIK, but not all systems really support it, so GPC supports both ways, to make it more likely to get the environment. But here, AFAICS, for the first way, we can do the same as for the arguments, and for the second one, we could use an internal flag, so the environment variable, if present, is only used once.
This require some changes in the RTS, but not too bad AFAICS. So if we decide that's what we need, I think I could do it quickly ...
I will be pleased with the change. Another idea is to create a separate routine for this (without parameters (or maybe only with the `Options' parameter))
procedure GPC_Lib_Initialize; attribute( name = '_p_lib_initialize');
GPC_Lib_Initialize can call into GPC_Intitialize with the right parameters. The advantage is that code doesn't break if the parameter list of GPC_Intitialize changes (as it did when the `Options' parameter was added). Then, GPC_Lib_Initialize is the routine to call when creating shared libraries or (e.g.) when linking Pascal code to a C program.
Regards,
Adriaan van Os