[Rcpp-devel] help with an error on windows 7 64bits
Jiqiang Guo
guojq28 at gmail.com
Wed Jul 11 04:34:58 CEST 2012
Thanks a lot. Could you please elaborate a little more as I did not get
some of
what you mentioned below?
Thanks,
Jiqiang
On Tue, Jul 10, 2012 at 9:30 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 10 July 2012 at 21:01, Jiqiang Guo wrote:
> | Dear List:
> |
> | I case across an error on Windows 7 64bits, any idea how can I avoid
> that?
> | I wish I could provide a demonstrative example, but it's too complicated
> now.
> |
> | This is the error report:
>
> It really helps when you show __code__ producing the error in question.
>
Sure. Sorry for that. As I said, I really wish to.
> Here I can only surmise that you used 'long long' which is not permitted on
> CRAN as its mandated compilers versions do not (yet) support C++11. Which
> is
> why Rcpp (as shipped from CRAN) cannot support it.
>
What do you mean by using long long? I do think I can use long long (or
size_t) in
my code. For example, the following works for me: [I do realize that on
windows,
I cannot use Rcpp::wrap(a) where a's type is size_t or Rcpp::as<size_t>(c),
so I got rid of
those wrap/as between size_t and SEXP.] Do you think I still have a place
where
I used wrap/as for long long type (or size_t)?
library(Rcpp)
library(inline)
src <- '
// size_t b = 100;
unsigned int b = 100;
Rcpp::List lst(a);
size_t a = Rcpp::as<unsigned int>(lst["a"]);
lst["b"] = b;
size_t c = 1000;
long long ll = 100;
#ifdef RCPP_HAS_LONG_LONG_TYPES
Rcpp::Rcout << "in ifdef" << std::endl;
#endif
Rcpp::NumericVector nv(c);
return lst;
'
fx <- cxxfunction(signature(a = 'list'), body = src, includes = '',
plugin = 'Rcpp', verbose = TRUE)
ll <- list(a=1, b=2, c=3);
fx(ll);
> It works if you use the
>
> -std=c++11
>
> flag as an option to PKG_CXXFLAGS for both Rcpp and Rstan --- but then you
> won't be able to upload this.
>
> Rcpp does this in RcppCommon.h: if g++ is used, and -std=c++11 has been
> activated, and if we see LONG_LONG_MAX (coming from the system headers)
> __then__ do we define RCPP_HAD_LONG_LONG_TYPES :
> package:
>
> #ifdef __GNUC__
> #ifdef __GXX_EXPERIMENTAL_CXX0X__
> #ifdef LONG_LONG_MAX
> __extension__ typedef long long int rcpp_long_long_type;
> __extension__ typedef unsigned long long int rcpp_ulong_long_type;
> #define RCPP_HAS_LONG_LONG_TYPES
> #endif
> #endif
> #endif
>
> You can protect your code with RCPP_HAD_LONG_LONG_TYPES tests in an
> #ifdef, a
> few of our packages do that as eg my most recent upload
>
> #ifdef RCPP_HAS_LONG_LONG_TYPES
> } else if (type == "integer") {
> int64_t *p = reinterpret_cast<int64_t*>(arr.data);
> ret = Rcpp::IntegerVector(p, p + shape[0]);
> #endif
>
> as int64_t does in fact become "long long int" on 32 bit systems...
>
> Dirk
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120710/11834931/attachment-0001.html>
More information about the Rcpp-devel
mailing list