Problem using ofstream in C++ class in package for MacOS X
On Sun, Feb 04, 2007 at 10:47:37PM +0100, cstrato wrote:
Seth Falcon wrote:
cstrato <cstrato at aon.at> writes:
Thank you for your fast answer.
Sorrowly, I don?t know how to use a debugger on MacOS X, I am using
old-style print commands.
You should be able to use gdb on OS X (works for me, YMMV). So you
could try:
R -d gdb
run
# source a script that causes crash
# back in gdb, use backtrace, etc.
+ seth
Dear Seth Thank you for this tip, I just tried it and here is the result: Welcome to MyClass
> writeFileCpp("myout_fileCpp.txt")
[1] "outfile = myout_fileCpp.txt"
Writing file myout_fileCpp.txt using C++ style.
---MyClassA::MyClassA()---------
---MyClassA::WriteFileCpp---------
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000006
0x020fe231 in std::ostream::flush (this=0x214f178) at
/Builds/unix/o403/i686-apple-darwin8/libstdc++-v3/include/bits/ostream.tcc:395
395
/Builds/unix/o403/i686-apple-darwin8/libstdc++-v3/include/bits/ostream.tcc:
No such file or directory.
in
/Builds/unix/o403/i686-apple-darwin8/libstdc++-v3/include/bits/ostream.tcc
(gdb)
It seems that it cannot find ostream.tcc, whatever this extension means.
Best regards
Christian
I also don't see what the problem is, but have a couple of thoughts. Under OS-X there is an environment variable you can define to get the dynamic linker to load debug versions of libraries. I can't remember what it is, but maybe something like DYLD_DEBUG (but probably DEBUG is part of the value of the variable). For that, or the tracing above, to be fully informative you need to have installed the appropriate debugging libraries and sources. You may need to set an explicit source search path in gdb to pick up the source files. Try stepping through the code from write before the crash to determine exactly where it runs into trouble. Does the output file you are trying to create exist? Unfortunately, none of this really gets at your core bug, but it might help track it down. Ross