[Rd] SEXPTYPEs

Duncan Murdoch murdoch.duncan at gmail.com
Fri May 16 12:06:24 CEST 2014


On 16/05/2014, 4:16 AM, Adrian Dușa wrote:
> Dear list,
>
> On a follow up from my previous email, I am now trying to allocate vectors
> of length larger than 32-bit in C.
>
>>From the R internals documentation, I read that:
> "The sxpinfo header is defined as a 32-bit C structure..."
> and
> "A SEXPREC is a C structure containing the 32-bit header..."
>
> The question is: does the INTSXP allow vectors larger than 32-bit?
>
>
> A test example:
>
> //###
> int *p_temp;
>
> SEXP root = PROTECT(allocVector(VECSXP, 5));
>
> long long int verylargeinteger;
> // something to compute verylargeinteger, > 32-bit
>
> SEXP temp = SET_VECTOR_ELT(root, 0, allocVector(INTSXP, verylargeinteger));
> p_temp = INTEGER(temp);
> //###
>
> "temp" should be a vector of length > 32-bit, and "p_temp" should be the
> pointer to that vector.
>
> If declaring:
> long long int *p_temp;
> (but the compiler throws a warning with an incompatible pointer type,
> because pointers should be integers of course).
>
> I've looked at all SEXPTYPEs in the R internals, and the only one specific
> to integer vectors is INTSXP. Can this be used for vectors of length larger
> than 32-bit?

Yes, see the section on "Long Vectors" in chapter 12.

Duncan Murdoch

>
> Thank you again, in advance,
> Adrian
>
>



More information about the R-devel mailing list