[R] Rinternals.h and iostream don't play nice together'

Faheem Mitha faheem at email.unc.edu
Mon Jan 31 00:28:18 CET 2005



On Sun, 30 Jan 2005, Dirk Eddelbuettel wrote:

>
> On 30 January 2005 at 18:03, Faheem Mitha wrote:
> | Consider the following file.
> |
> | *******************************
> | foo.cc
> | *******************************
> | #include <R.h>
> | #include <Rinternals.h>
> | #include <iostream>
> | *******************************
> |
> | R CMD SHLIB foo.cc
>
> Two changes are required: You absolutely do need extern "C" ... to get C
> headers in with C++, and the other is a simple reordering -- not sure where I
> learned that can help at times ...
>
> edd at basebud:/tmp> cat foo.cc
> #include <iostream>
> extern "C" {
>  #include <R.h>
>  #include <Rinternals.h>
> }

Ok, but R.h and Rinternals.h are already wrapped in extern "C", as you can 
check, so this is superfluous.

I've verified that putting iostream first fixes this, but this is really a 
workaround, though still useful for me.

Thanks.                                                          Faheem.




More information about the R-help mailing list