Dear all, I am currently learning how to create R packages using C++ classes. For this purpose I have written a small package MyClass (which I try to attach since I do not have access to a website).
MyClass has methods WriteFileC() and WriteFileCpp() which implement C-style and C++-style writing of a table to a file using FILE or ofstream respectively, and the corresponding R-functions writeFileC.R and writeFileCpp.R. While I can compile and execute my package w/o problems on Fedora Core 4,I can only execute writeFileC.R on my Intel-MacBook Pro, but not writeFileCpp.R.
Executing my functions I get the following output: > library(MyClass) Welcome to MyClass > writeFileC("myout_fileC.txt") [1] "outfile = myout_fileC.txt" Writing file myout_fileC.txt using C style. ---MyClassA::MyClassA()--------- ---MyClassA::WriteFileC--------- <20> records exported. ---MyClassA::~MyClassA()--------- [1] "writeFileC finished" NULL > writeFileCpp("myout_fileCpp.txt") [1] "outfile = myout_fileCpp.txt" Writing file myout_fileCpp.txt using C++ style. ---MyClassA::MyClassA()--------- ---MyClassA::WriteFileCpp--------- *** caught bus error *** address 0x6, cause 'non-existent physical address' Traceback: 1: .C("WriteFileCpp", as.character(outfile), PACKAGE = "MyClass") 2: writeFileCpp("myout_fileCpp.txt") While I understand, that C++ iostreams are best avoided, since there is no guarantee that the output will appear in the R console (as mentioned on page 62 of R-exts.pdf), I do not understand why I cannot use ofstream, which is isolated in a C++ method only. Is there a way how to use ofstream on MacOS X or is this a limit of the current Mac implementation? Thank you in advance. Best regards Christian _._._._._._._._._._._._._._._._ C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a V.i.e.n.n.a A.u.s.t.r.i.a _._._._._._._._._._._._._._._._
MyClass_0.1.2.tar.gz
Description: GNU Zip compressed data
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel