Skip to content
Prev 40170 / 63421 Next

cerr and cout not working calling c++ from R

Thanks, Simon,
That link may prove to be very useful. I think what I can do is make a
similar version of a buffer to one in that example and then have it
conditionally write to Rprintf or cout and/or REprintf or cerr,
depending on whether I'm running a c++ program from the command line
or launching a function from R. Then I can just replace all of my cout
and cerr terms with this new buffer or two in global space. Before I
call those functions in R, I'll set them to write to R before I launch
any code that uses it. This should allow me to leave all my code
exactly how it is with a minor replacement of one or two terms for
another. So, if the errors in my performance are only caused by
writing to cout and/or cerr from R, then they can be completely
avoided by all of those substitutions writing to Rprintf and REprintf.
This seems like it is going to work exactly as I'm hoping.
Thanks again,
Sean

On Sat, May 7, 2011 at 6:13 PM, Simon Urbanek
<simon.urbanek at r-project.org> wrote: