An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121207/a9141e78/attachment.pl>
Use .Call interface
2 messages · Shangru Li, William Dunlap
You may have an unfinished statement in Projector.h, which you didn't show. (The error message says line 5, which is immediately after #include "Projector.h".) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
Of Shangru Li
Sent: Thursday, December 06, 2012 11:36 AM
To: r-help at r-project.org
Subject: [R] Use .Call interface
Hi
I've written the following program:
#include <R.h>
#include <Rdefines.h>
#include "Projector.h"
SEXP Projector2(SEXP L, SEXP G, SEXP W, SEXP xymod, SEXP modif){
int nprot=0;
PROTECT(L=AS_NUMERIC(L));nprot++;
PROTECT(G=AS_NUMERIC(G));nprot++;
PROTECT(W=AS_NUMERIC(W));nprot++;
PROTECT(xymod=AS_INTEGER(xymod));nprot++;
PROTECT(modif=AS_NUMERIC(modif));nprot++;
double *lptr; lptr=REAL(L);
double *gptr; gptr=REAL(G);
double *wptr; wptr=REAL(W);
int *xyptr; xyptr=INTEGER(xymod);
double *ifptr; ifptr=REAL(modif);
int *dimL; dimL=INTEGER(GET_DIM(L));
int *dimG; dimG=INTEGER(GET_DIM(G));
int *dimW; dimW=INTEGER(GET_DIM(W));
int *dimxy; dimxy=INTEGER(GET_DIM(xymod));
int *dimif; dimif=INTEGER(GET_DIM(modif));
SEXP ans;
PROTECT(ans=allocMatrix(REALSXP, dimG[0], dimL[1])); nprot++;
double *ansptr; ansptr=REAL(ans);
Projector(lptr, dimL, gptr, dimG, wptr, dimW, xyptr, dimxy, ifptr, dimif,
ansptr);
UNPROTECT(nprot);
return ans;
}
The question is that the function "Projector" runs well, but when I try:
R CMD SHLIB Projector2.c Projector.c
It shows:
Projector2.c: In function 'Projector':
Projector2.c:5:64: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '{' token
Projector2.c:28:1: error: expected '{' at end of input
make: *** [Projector2.o] Error 1
Warning message:
running command 'R CMD SHLIB Projector2.c Projector.c' had status 1
What's the problem? Thanks all!
Regards
Li Shangru
--
Department of Mathematics,
National University of Singapore,
Blk S17, 10 Lower Kent Ridge Road,
119076
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.