[R] rtools fstream error
sunaga at telenet.be
sunaga at telenet.be
Mon Feb 2 22:11:37 CET 2015
Hi,
when writing a simple cpp function to be run in R I obtain a compilation error as soon as I include fstream. Any hints of what goes wrong and how to fix it? It's Windows 7 64-bit, R-3.1.2 and Rtools32. An example to recreate the error:
#include <R.h>
#include <Rdefines.h>
#include <fstream>
using namespace std;
extern "C" SEXP test(SEXP x) {
SEXP result;
PROTECT(result = allocVector(REALSXP,1));
REAL(result)[0] = REAL(x)[0]*5;
UNPROTECT(1);
return result;
}
Output:
> R CMD SHLIB test.cpp
g++ -m64 -I"C:/PROGRA~1/R/R-31~1.2/include" -DNDEBUG -I"d:/RCompile/CRANpkg/
extralibs64/local/include" -O2 -Wall -mtune=core2 -c test.cpp -o test.o
In file included from c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/
../../../../include/c++/4.6.3/fstream:42:0,
from test.cpp:3:
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c+
+/4.6.3/bits/codecvt.h:216:45: error: macro "length" passed 4 arguments, but tak
es just 1
In file included from c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/
../../../../include/c++/4.6.3/fstream:921:0,
from test.cpp:3:
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c+
+/4.6.3/bits/fstream.tcc:826:60: error: macro "length" passed 4 arguments, but t
akes just 1
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c+
+/4.6.3/bits/fstream.tcc:943:39: error: macro "length" passed 4 arguments, but t
akes just 1
In file included from c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/
../../../../include/c++/4.6.3/fstream:42:0,
from test.cpp:3:
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c+
+/4.6.3/bits/codecvt.h:215:7: error: expected ';' at end of member declaration
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c+
+/4.6.3/bits/codecvt.h:217:7: error: expected unqualified-id before '{' token
make: *** [test.o] Error 1
Thanks,
sunaga
More information about the R-help
mailing list