[Rd] Problem using ofstream in C++ class in package for MacOS X
cstrato at aon.at
Sun Feb 4 20:17:51 CET 2007
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
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
Executing my functions I get the following output:
Welcome to MyClass
 "outfile = myout_fileC.txt"
Writing file myout_fileC.txt using C style.
<20> records exported.
 "writeFileC finished"
 "outfile = myout_fileCpp.txt"
Writing file myout_fileCpp.txt using C++ style.
*** caught bus error ***
address 0x6, cause 'non-existent physical address'
1: .C("WriteFileCpp", as.character(outfile), PACKAGE = "MyClass")
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 9198 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-devel/attachments/20070204/2e7fb79c/attachment.gz
More information about the R-devel