[Rd] printf capture

mel mel at altk.com
Thu Apr 12 16:17:51 CEST 2007


Prof Brian Ripley a écrit :

> If you are using Rgui (it should work under rterm) 

yes indeed, it works under rterm

> there is no C-level 'stdout' file stream (the normal state
> for Windows GUI programs), so no way to capture it inside R.

Aie ! (I feared this answer). Thanks however for the explanation.
I was looking at pipe(), scan() etc.
So, no hope from this side.

> If you have the program, can you not edit it before compiling it?
> Adding
> #define printf Rprintf
> will probably do the trick.

yes thanks, I already though on that, and it works.
But i would have preferred not touching this 3rd party code.

=====================================

There is another little annoyance (always on WindowsXP + R-2.4.1)
When including both <windows.h> and <R.h>
#include <windows.h>
#include <R.h>	

There is a #define ERROR redefinition

#define ERROR ),error(R_problem_buf);} // this one in Rs.h
#define ERROR 0                        //  in MinGW/.../wingdi.h

It's only a warning, but i would prefer to avoid it
and i'm searching how to avoid it.
Thanks for any idea.


PS : compilation details :

g++ -IJ:/softs/R-2.4.1/include -c f1.cpp -o f1.o
In file included from J:/softs/R-2.4.1/include/R.h:49,
                  from f1.cpp:11:
J:/softs/R-2.4.1/include/R_ext/RS.h:40:1: warning: "ERROR" redefined
In file included from
f:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windows.h:52,
                  from f1.cpp:10:
f:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/wingdi.h:313:1:
warning: this is the location of the previous definition



More information about the R-devel mailing list