Re: [Rd] cerr and cout not working calling c++ from R

2011-05-10 Thread Sean Robert McGuffee
Just a short follow up to the list. It turns out that the strange behavior I was experiencing had nothing to do with cout and cerr, but ostreams in general. For some reason, at a minimum, the operators: ostream& operator<< (long& val ); ostream& operator<< (double& val ); were not functioning prop

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-07 Thread Sean Robert McGuffee
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

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-07 Thread Simon Urbanek
Sean, just to clarify - this is not about something "not working" or any leaks. cout/cerr do exactly what they are supposed to, it's just in most cases not what you want. The main reason is that R does not necessarily use stdin/stdout so cout/cerr may have nothing to do with the R console outpu

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-06 Thread Sean Robert McGuffee
This is a good idea as to converting to stringstream's because it could let me remove cout and cerr from the equation. At the moment, I get that feeling from the experts that having cout and cerr is causing a bug by not mixing with R. I have other cases where algorithms that avoid cout and cerr are

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-06 Thread Dirk Eddelbuettel
On 6 May 2011 at 22:09, Simon Urbanek wrote: | Sean, | | the path form the console is not under your control and it depends heavily on the internal settings in R (is console enabled, is R interactive, is the output a tty or a file ...) - that's why you have to use Rprint/REprintf - that's the

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-06 Thread Simon Urbanek
Sean, the path form the console is not under your control and it depends heavily on the internal settings in R (is console enabled, is R interactive, is the output a tty or a file ...) - that's why you have to use Rprint/REprintf - that's the only path that is guaranteed to work. Anything else

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-06 Thread Sean Robert McGuffee
Hi, Thanks for the comments so far. I've been going through the code extensively and seem to be having trouble reproducing what R is doing, so this confuses me. For example, when I write out the pointer values for ptr_R_WriteConsole type functions, I can't find a function that matches what is act

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-06 Thread Davor Cubranic
On 2011-05-06, at 11:41 AM, Dirk Eddelbuettel wrote: > | I¹m trying to call some of my c++ code from R and seem to be having an issue > | with streams, although that¹s just one obvious sign of something different > | in performance between calling the same function from main in c++ vs. > | calling

Re: [Rd] cerr and cout not working calling c++ from R

2011-05-06 Thread Dirk Eddelbuettel
On 6 May 2011 at 14:21, Sean Robert McGuffee wrote: | Hi, | | Sorry, I just tried posting this but I had it in the wrong format of text, | so this is a cleared format repost: | | I¹m trying to call some of my c++ code from R and seem to be having an issue | with streams, although that¹s just one

[Rd] cerr and cout not working calling c++ from R

2011-05-06 Thread Sean Robert McGuffee
Hi, Sorry, I just tried posting this but I had it in the wrong format of text, so this is a cleared format repost: I¹m trying to call some of my c++ code from R and seem to be having an issue with streams, although that¹s just one obvious sign of something different in performance between calling