Hello Howard,
Thank you for your suggestion. I've changed my code accordingly. Tracing
into std::ios_base::Init::Init() and then __nInit::__nInit(), I see the
following.
__nInit::ninit_cnt_s equals 13 the first time I reach that codepoint.
Next the block guarded by
if (ninit_cnt_s == 0)
{
new (&cin)istream(&fin);
new (&cout)ostream(&fout);
new (&cerr)ostream(&ferr);
new (&clog)ostream(&ferr);
cin.tie(&cout);
cerr.setf(ios_base::unitbuf);
fin.pubsetbuf(0, 0);
fout.pubsetbuf(0, 0);
ferr.pubsetbuf(0, 0);
}
is skipped. This eventually leads up to the problem I described earlier.
Even when I break at the entry point of the Bundle Package, the Global
Variables dialog tell me that both std::__nInit::ninit_cnt_s and
std::__wInit::winit_cnt_s equal 13.
Looking at lines 54, 55 of MSL/MSL_C++/MSL_Common/Src/iostream.cpp I see
the following:
int __nInit::ninit_cnt_s;
int __wInit::winit_cnt_s;
I would have expected:
int __nInit::ninit_cnt_s = 0;
int __wInit::winit_cnt_s = 0;
So I changed this code to the above. Rebuild the MSL_C++_Mach-O library.
Included MSL_C++_Mach-O.lib, MSL_C_Mach-O.lib and MSL_Runtime_Mach-O.lib
instead of MSL_All_Mach-O.lib.
Now the debugger came up with only assembly, but I think I've located
the 'if (ninit_cnt_s == 0)': (Please bear with me, the last time I did
some serious assembly was in way back in 1985 on a Rockwell 6502)
....
lwz RTOC, 12932(r3)
addi r0, RTOC, 1
cmpwi RTOC, 0x0000
stw r0, 12932(r3)
bne std::__nInit::__nInit()+0x5A800
....
In the Register Window, General Registers, register R0 contains 0x0D.
Note that, after I changed the libraries, in the Gloabel Variables
window, I could not find std::__nInit::ninit_cnt_s and
std::__wInit::winit_cnt_s any more.
Is this where Ron's remarks about the linker initialization point come
into play?
Have you got any more suggestions?
With kind regards,
Peter Paulus
Howard Hinnant wrote:
> In article <4034E1D8.9000508 RemoveThis @neroc.nl>, Peter Paulus <peter RemoveThis @neroc.nl>
> wrote:
>
>
>>Would you be so kind as to tell me what initialization function can be
>>used to initialize std::cout (and others) correctly.
>
>
> Try constructing an object of type: std::ios_base::Init
>
> #include <ios>
>
> int main()
> {
> std::ios_base::Init construct_streams;
> }
>
> -Howard<!-- ~MESSAGE_AFTER~ -->
>> Stay informed about: comp.sys.mac.programmer.codewarrior