Hello all, hello Frank,
- writeln (s.capacity), where s is a global string variable. If my theory is correct, it should write 0 or some nonsense value, instead of the correct capacity. That's why a wrong value will be passed to the read routine, and the varargs are not guilty.
It's 0 indeed.
- s.capacity := 255 (or whatever your capacity is) before the read. Then the read should work. This can serve as a workaround, just like the explicit InitFDR, until the real problem is found.
This works all right.
- Move all the code and (especially!) the variable declarations into a procedure. Then, both issues should be OK.
This works fine.
Try a unit (or module) with initialization code, e.g. the following:
file foo.pas:
program foo; uses bar; begin end.
file bar.pas:
unit bar; interface implementation to begin do writeln('Hello, world'); end.
Then `gpc foo.pas bar.pas' or `gpc --automake foo.pas', and see if it writes anything.
It doesn't write anything...
- Try your test program (one with a global file variable) with RTS debugging. That's a little more complicated:
I'll check that out as soon as I have the time...
Now for the reason why the initialization code of the program is not executed. I think I have got bad news:
IOW, it just ignores the initialization and finalization code! Great, isn't it? :-(
Djeez, that's a nice feature!!!! Makes me think of M$ productes ;-)
So, what can be done:
- Implement this feature for your platform. But since you don't program in assembler, I don't suppose you know how to do this. I don't, either, but I suppose it's even more difficult than "ordinary" assembler programming...
I don't feel ready to do this...
- Find someone to implement it, perhaps in the GCC mailing lists or newsgroups. But seeing how much most C programmers "love" Pascal, I wish you best luck...
What's the address for the gcc mailing lists? If we present it as a "serious" bug in the rs6000 code, then maybe we can convince someone...
Here's another possible workaround:
Actually, workarounds are out of the question for us. We are testing the gpc compiler because we want to port our code written in xlp (IBM) pascal to different other platforms. From what we read in the documentation, gpc should be able to compile our xlp programs without many modifications (the only one we noticed so far is the interchange of %include (xlp) by #include (gpc). If we have to add all these workarounds, the project becomes, well, not viable. We want to port from AIX to Solaris, Linux and (yikes) NT.
Can't I hack something with the p_collect_flag and __init_program_xxx in the _p_run_constructors routine?
Nick