From murdoch.duncan at gmail.com  Fri May 16 12:06:24 2014
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Fri, 16 May 2014 06:06:24 -0400
Subject: [Rd] SEXPTYPEs
In-Reply-To: <CAJ=0CtBEqPzDQcCkRPat1d51DprFPjZpQR3BiooSiFWfPE-EPA@mail.gmail.com>
References: <CAJ=0CtBEqPzDQcCkRPat1d51DprFPjZpQR3BiooSiFWfPE-EPA@mail.gmail.com>
Message-ID: <5375E320.8080007@gmail.com>

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
>
>



[Rd] SEXPTYPEs
Duncan Murdoch