From sean.mcguffee at gmail.com  Fri May  6 20:21:01 2011
From: sean.mcguffee at gmail.com (Sean Robert McGuffee)
Date: Fri, 06 May 2011 14:21:01 -0400
Subject: [Rd] cerr and cout not working calling c++ from R
Message-ID: <C9E9B44D.409E%sean.mcguffee@gmail.com>

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 the same function from main in c++ vs.
calling the same function from R. I?m not getting any signs of errors from
R, but the behavior is different somehow and in a way that breaks my
algorithms. In both cases of launching a function from c++ or R, I redirect
cout to a file using a streambuf. In particular, I can see progress stop
when launching from R at a point when cout gets truncated when starting to
write out iterator values in a std::vector<string>. Then, I find no way to
write anything else to cout. When I write those values to Rprintf, they are
there and they are as expected. I?ve tried setting
ios_base::sync_with_stdio(false) in case R is messing with stdout and stderr
somehow, but that made no difference. I?m not quite sure how R uses those C
FILE* streams. Anyway, I am wondering if anyone has a hunch as to what might
be going on. At this point I don?t know if it might be an issue with R not
completely handling c++ from a library or if it is an issue with cout in
particular or if there is something else I?m missing. Please let me know if
you have any suggestions for me.

Thanks,
Sean



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