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

Jeffrey Horner jeff.horner at vanderbilt.edu
Thu Feb 3 16:20:26 CET 2005


Faheem Mitha wrote:
> 
> 
> On Sun, 30 Jan 2005, Paul Roebuck wrote:
> 
>> and if you use the following instead of "Rinternals.h"?
>> extern "C" {
>> #include <Rdefines.h>
>> }
> 
> 
> Still the same errors. As Dirk pointed out, putting iostream first makes 
> the errors go away in either case.

You have to define R_NO_REMAP in your code before you include
Rinternals.h, as the "Writing R Extensions" manual states. If not,
Rinternals.h will define the length macro (and others...) which is
defined somewhere within iostream or included from iostream.

I caught this in the 7th line of error output:

$ g++ -I/usr/local/lib/R/include -g -c foo.cc
In file included from /usr/include/c++/3.3/bits/locale_facets.h:528,
                  from /usr/include/c++/3.3/bits/basic_ios.h:44,
                  from /usr/include/c++/3.3/ios:51,
                  from /usr/include/c++/3.3/ostream:45,
                  from /usr/include/c++/3.3/iostream:45,
                  from foo.cc:3:
/usr/include/c++/3.3/bits/codecvt.h:110:52: macro "length" passed 4
arguments, but takes just 1
...

It's good to read error messages.

Cheers,
-- 
Jeffrey Horner       Computer Systems Analyst         School of Medicine
615-322-8606         Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list