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

Faheem Mitha faheem at email.unc.edu
Mon Jan 31 00:03:29 CET 2005


Hi,

Consider the following file.

*******************************
foo.cc
*******************************
#include <R.h>
#include <Rinternals.h>
#include <iostream>
*******************************

R CMD SHLIB foo.cc

gives scads of errors. I've use C++ extensively with R before (using C 
linkage) but not with Rinternals.h. I'm puzzled. The errors make no sense 
to me. Am I doing something wrong? Is it impossible to use iostream here 
for some reason?

I'm using Debian Sarge with R 2.0.1 and gcc 3.3.5. Please cc me; I'm not 
subscribed. Thanks in advance.

                                                               Faheem.

R CMD SHLIB foo.cc
g++ -I/usr/lib/R/include     -fPIC  -g -O2 -c foo.cc -o foo.o
************************************************************************
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
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:109: error: parse error before `const'
/usr/include/c++/3.3/bits/codecvt.h:113: error: semicolon missing after
    declaration of `std::__codecvt_abstract_base<_InternT, _ExternT, _StateT>'
/usr/include/c++/3.3/bits/codecvt.h:115: error: ISO C++ forbids defining types
    within return type
/usr/include/c++/3.3/bits/codecvt.h:115: error: extraneous `int' ignored
/usr/include/c++/3.3/bits/codecvt.h:115: error: non-member function `
    std::__codecvt_abstract_base<_InternT, _ExternT, _StateT> std::max_length()'
    cannot have `const' method qualifier
/usr/include/c++/3.3/bits/codecvt.h:115: error: semicolon missing after
    declaration of `class std::__codecvt_abstract_base<_InternT, _ExternT,
    _StateT>'
/usr/include/c++/3.3/bits/codecvt.h: In function `int std::max_length()':
/usr/include/c++/3.3/bits/codecvt.h:115: error: invalid use of `this' in
    non-member function
/usr/include/c++/3.3/bits/codecvt.h: At global scope:
/usr/include/c++/3.3/bits/codecvt.h:117: error: parse error before `protected'
/usr/include/c++/3.3/bits/codecvt.h:122: error: destructors must be member
    functions
/usr/include/c++/3.3/bits/codecvt.h:122: error: virtual outside class
    declaration
/usr/include/c++/3.3/bits/codecvt.h: In function `void
    std::__codecvt_abstract_base()':
/usr/include/c++/3.3/bits/codecvt.h:122: error: `void
    std::__codecvt_abstract_base()' redeclared as different kind of symbol
/usr/include/c++/3.3/bits/codecvt.h:65: error: previous declaration of `
    template<class _InternT, class _ExternT, class _StateT> class
    std::__codecvt_abstract_base<_InternT,_ExternT,_StateT>'
/usr/include/c++/3.3/bits/codecvt.h:65: error: previous non-function
    declaration `template<class _InternT, class _ExternT, class _StateT> class
    std::__codecvt_abstract_base<_InternT,_ExternT,_StateT>'
/usr/include/c++/3.3/bits/codecvt.h:122: error: conflicts with function
    declaration `void std::__codecvt_abstract_base()'
/usr/include/c++/3.3/bits/codecvt.h: At global scope:
/usr/include/c++/3.3/bits/codecvt.h:125: error: syntax error before `(' token
/usr/include/c++/3.3/bits/codecvt.h:131: error: syntax error before `(' token
/usr/include/c++/3.3/bits/codecvt.h:135: error: syntax error before `(' token
/usr/include/c++/3.3/bits/codecvt.h:141: error: virtual outside class
    declaration
/usr/include/c++/3.3/bits/codecvt.h:141: error: non-member function `int
    std::do_encoding()' cannot have `const' method qualifier
/usr/include/c++/3.3/bits/codecvt.h:141: error: function `int
    std::do_encoding()' is initialized like a variable
/usr/include/c++/3.3/bits/codecvt.h:144: error: virtual outside class
    declaration
/usr/include/c++/3.3/bits/codecvt.h:144: error: non-member function `bool
    std::do_always_noconv()' cannot have `const' method qualifier
/usr/include/c++/3.3/bits/codecvt.h:144: error: function `bool
    std::do_always_noconv()' is initialized like a variable
/usr/include/c++/3.3/bits/codecvt.h:147: error: parse error before `&' token
/usr/include/c++/3.3/bits/codecvt.h:148: error: virtual outside class
    declaration
/usr/include/c++/3.3/bits/codecvt.h:148: error: non-member function `int
    std::do_length(...)' cannot have `const' method qualifier
/usr/include/c++/3.3/bits/codecvt.h:148: error: function `int
    std::do_length(...)' is initialized like a variable
/usr/include/c++/3.3/bits/codecvt.h:151: error: virtual outside class
    declaration
/usr/include/c++/3.3/bits/codecvt.h:151: error: non-member function `int
    std::do_max_length()' cannot have `const' method qualifier
/usr/include/c++/3.3/bits/codecvt.h:151: error: function `int
    std::do_max_length()' is initialized like a variable
/usr/include/c++/3.3/bits/codecvt.h:158: error: parse error before `<' token
/usr/include/c++/3.3/bits/codecvt.h:163: error: syntax error before `;' token
/usr/include/c++/3.3/bits/codecvt.h:164: error: syntax error before `;' token
/usr/include/c++/3.3/bits/codecvt.h:165: error: syntax error before `;' token
/usr/include/c++/3.3/bits/codecvt.h:172: error: only declarations of
    constructors can be `explicit'
/usr/include/c++/3.3/bits/codecvt.h: In function `int codecvt(unsigned int)':
/usr/include/c++/3.3/bits/codecvt.h:172: error: `int codecvt(unsigned int)'
    redeclared as different kind of symbol
/usr/include/c++/3.3/bits/codecvt.h:158: error: previous declaration of `
    template<class _InternT, class _ExternT, class _StateT> class codecvt'
/usr/include/c++/3.3/bits/codecvt.h:158: error: previous non-function
    declaration `template<class _InternT, class _ExternT, class _StateT> class
    codecvt'
/usr/include/c++/3.3/bits/codecvt.h:172: error: conflicts with function
    declaration `int codecvt(unsigned int)'
/usr/include/c++/3.3/bits/codecvt.h:172: error: only constructors take base
    initializers
/usr/include/c++/3.3/bits/codecvt.h:172: error: parse error before `<' token
/usr/include/c++/3.3/bits/codecvt.h:172: confused by earlier errors, bailing out
make: *** [foo.o] Error 1




More information about the R-help mailing list