diff --git a/inst/include/bigmemory/util.h b/inst/include/bigmemory/util.h index 86209ab..327e9d0 100644 --- a/inst/include/bigmemory/util.h +++ b/inst/include/bigmemory/util.h @@ -1,8 +1,6 @@ #ifndef BIGMEMORY_UTIL_HPP #define BIGMEMORY_UTIL_HPP -#include - #include "bigmemoryDefines.h" using namespace std; @@ -38,9 +36,6 @@ SEXP StringVec2RChar( const vector &strVec, } */ -#undef length -#include - template struct NewVec; @@ -79,5 +74,4 @@ template<> struct VecPtr {double* operator()(SEXP vec) const {return NUMERIC_DATA(vec);};}; -#define length(x) Rf_length(x) #endif // BIGMEMORY_UTIL_HPP diff --git a/src/bigmemory.cpp b/src/bigmemory.cpp index 1f890bf..4ce3738 100644 --- a/src/bigmemory.cpp +++ b/src/bigmemory.cpp @@ -4,9 +4,16 @@ #include "bigmemory/BigMatrix.h" #include "bigmemory/MatrixAccessor.hpp" -#include "bigmemory/util.h" #include "bigmemory/isna.hpp" +// undefine length which Rcpp maps to Rf_length and uses as member function +#undef length +#include +// but redefine it to Rf_length for subsequent use below and in util.h +#define length Rf_length + +#include "bigmemory/util.h" + /* Notes * R does not natively contain float type objects * Therefore, every time you pass object to see they will initially be diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index 11e936d..be6fd5b 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -7,15 +7,13 @@ #include "bigmemory/BigMatrix.h" #include "bigmemory/MatrixAccessor.hpp" -#include "bigmemory/util.h" #include "bigmemory/isna.hpp" -#include -#include -#include -#include -#include -#include +// undefine length which Rcpp maps to Rf_length and uses as member function +#undef length +#include +// but redefine it to Rf_length for subsequent use below and in util.h +#define length Rf_length template