[Rcpp-devel] 64-bit ints on Windows 64-bit via size_t, unsigned long long, or unsigned __int64
Bob Carpenter
carp at alias-i.com
Wed Jul 11 21:34:35 CEST 2012
Jiqiang created a standalone example that illustrates
our problem with wrapping size_t into Rcpp on Win64.
The simple example is as follows (full running dump
from R/Rcpp below):
size_t b = 100;
Rcpp::List lst(a);
lst["b"] = b;
return lst;
We found this discussion:
http://stackoverflow.com/questions/8931123/return-wrap-of-size-t-in-rcpp
where Romain suggests just avoiding size_t and long long
altogether. We're willing to fly in the face of all the
other advice we've ever gotten (which is to use "size_t" for
portability), but we don't know how to specify the type of
size_t in Win64 given that Romain doesn't want us to use
"size_t" or "unsigned long long". Unfortunately, "unsigned long"
is only 32 bits on Windows.
I'm following Dirk's final comment on Stack Overflow
and "taking it to the [rcpp] list".
How should we specify the type of size_t in
Windows 64 bit given that we can't say "size_t" or "unsigned
long long"? The only other option seems to be "unsigned __int64".
Here's the full table of types from the horse's mouth:
http://msdn.microsoft.com/en-us/library/s3f49ktz(v=VS.80).aspx
- Bob Carpenter & Jiqiang Guo
Columbia Uni., Dept. of Statistics
P.S. Here's the full dump:
> library(Rcpp)
> library(inline)
>
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] inline_0.3.8 Rcpp_0.9.13
>
> src <- '
+ size_t b = 100;
+ Rcpp::List lst(a);
+ lst["b"] = b;
+ return lst;
+ '
>
> fx <- cxxfunction(signature(a = 'list'), body = src, includes = '',
+ plugin = 'Rcpp', verbose = !TRUE)
In file included from C:/Program
Files/R/R-2.15.1/library/Rcpp/include/RcppCommon.h:326:0,
from C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp.h:27,
from file8c8759b1a9b.cpp:4:
C:/Program Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:
In function 'SEXPREC*
Rcpp::internal::wrap_dispatch_unknown_iterable(const T&,
Rcpp::traits::false_type) [with T = long long unsigned int, SEXP =
SEXPREC*, Rcpp::traits::false_type =
Rcpp::traits::integral_constant<bool, false>]':
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:638:98:
instantiated from 'SEXPREC* Rcpp::internal::wrap_dispatch_unknown(const
T&, Rcpp::traits::false_type) [with T = long long unsigned int, SEXP =
SEXPREC*, Rcpp::traits::false_type =
Rcpp::traits::integral_constant<bool, false>]'
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:654:96:
instantiated from 'SEXPREC* Rcpp::internal::wrap_dispatch_eigen(const
T&, Rcpp::traits::false_type) [with T = long long unsigned int, SEXP =
SEXPREC*, Rcpp::traits::false_type =
Rcpp::traits::integral_constant<bool, false>]'
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:669:80:
instantiated from 'SEXPREC*
Rcpp::internal::wrap_dispatch_unknown_importable(const T&,
Rcpp::traits::false_type) [with T = long long unsigned int, SEXP =
SEXPREC*, Rcpp::traits::false_type =
Rcpp::traits::integral_constant<bool, false>]'
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:687:99:
instantiated from 'SEXPREC* Rcpp::internal::wrap_dispatch(const T&,
Rcpp::traits::wrap_type_unknown_tag) [with T = long long unsigned int,
SEXP = SEXPREC*]'
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:791:104:
instantiated from 'SEXPREC* Rcpp::wrap(const T&) [with T = long long
unsigned int, SEXP = SEXPREC*]'
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/vector/proxy.h:155:4:
instantiated from 'Rcpp::internal::generic_name_proxy<RTYPE>&
Rcpp::internal::generic_name_proxy<RTYPE>::operator=(const T&) [with T =
long long unsigned int, int RTYPE = 19,
Rcpp::internal::generic_name_proxy<RTYPE> =
Rcpp::internal::generic_name_proxy<19>]'
file8c8759b1a9b.cpp:33:14: instantiated from here
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:433:11:
error: invalid conversion from 'long long unsigned int' to 'SEXP'
[-fpermissive]
make: *** [file8c8759b1a9b.o] Error 1
ERROR(s) during compilation: source code errors or compiler
configuration errors!
Program source:
1:
2: // includes from the plugin
3:
4: #include <Rcpp.h>
5:
6:
7: #ifndef BEGIN_RCPP
8: #define BEGIN_RCPP
9: #endif
10:
11: #ifndef END_RCPP
12: #define END_RCPP
13: #endif
14:
15: using namespace Rcpp;
16:
17:
18: // user includes
19:
20:
21: // declarations
22: extern "C" {
23: SEXP file8c8759b1a9b( SEXP a) ;
24: }
25:
26: // definition
27:
28: SEXP file8c8759b1a9b( SEXP a ){
29: BEGIN_RCPP
30:
31: size_t b = 100;
32: Rcpp::List lst(a);
33: lst["b"] = b;
34: return lst;
35:
36: END_RCPP
37: }
38:
39:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file
included from C:/Program
Files/R/R-2.15.1/library/Rcpp/include/RcppCommon.h:326:0,
from C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp.h:27,
from file8c8759b1a9b.cpp:4:
C:/Program Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:
In function 'SEXPREC*
Rcpp::internal::wrap_dispatch_unknown_iterable(const T&,
Rcpp::traits::false_type) [with T = long long unsigned int, SEXP =
SEXPREC*, Rcpp::traits::false_type =
Rcpp::traits::integral_constant<bool, false>]':
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:638:98:
instantiated from 'SEXPREC* Rcpp::internal::wrap_dispatch_unknown(const
T&, Rcpp::traits::false_type) [with T = long long unsigned int, SEXP =
SEXPREC*, Rcpp::traits::false_type =
Rcpp::traits::integral_constant<bool, false>]'
C:/Program
Files/R/R-2.15.1/library/Rcpp/include/Rcpp/internal/wrap.h:654:96:
instantiated from 'SEXPREC* R
Calls: cxxfunction -> compileCode
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-215~1.1/bin/x64/R CMD SHLIB
file8c8759b1a9b.cpp 2> file8c8759b1a9b.cpp.err.txt' had status 1
Execution halted
More information about the Rcpp-devel
mailing list