Diogo Alagador
2007-Jul-20 18:17 UTC
[R] Unrecognising SEXP [C file compilation using .Call]
Following an exercise suggestion I went to compile a C file, now with the .Call
interface to R. The C file is:
#include <R.h>
#include <Rdefines.h>
SEXP getInt(SEXP myint, SEXP myintVar) {
int Imyint, n; // declare an integer variable
int *Pmyint; // pointer to an integer vector
PROTECT(myint = AS_INTEGER(myint));
Imyint = INTEGER_POINTER(myint)[0];
Pmyint = INTEGER_POINTER(myint);
n = INTEGER_VALUE(myintVar);
printf(" Printed from C: \n");
printf(" Imyint: %d \n", Imyint);
printf(" n: %d \n", n);
printf(" Pmyint[0], Pmyint[1]: %d %d \n",
Pmyint[0], Pmyint[1]);
UNPROTECT(1);
return(R_NilValue);
}
Compiling with R CMD SHLIB or with any specific compiler to C/C++ gave an
unrecognition of SEXP.
What actually is SEXP? What is for? Why wasn't recognized?
Thanks again,
Diogo Andre' Alagador
[[alternative HTML version deleted]]