[Rcpp-devel] C++ Throwing Exception.

romain at r-enthusiasts.com romain at r-enthusiasts.com
Wed Dec 22 13:17:09 CET 2010


Hello, 

That is because you are not throwing an exception, but a "const char*" and END_RCPP does not recognize this type. Maybe it should. 

You can either create your own exception class or use one from the standard set: http://cplusplus.com/reference/std/exception/exception/

Romain

 Le mer 22/12/10 11:56, "Cedric Ginestet" c.ginestet05 at googlemail.com a écrit:
> Dear Rcpp experts,
> 
> I have got another problem with the throw of exception in C++
> channelled into R. Apologies but these codes are not reproducible: I
> didn't succeed to use the BEGIN_RCPP ... END_RCPP commands with the
> inline-package. Help regarding this would be also welcomed. 
> 
> #################################################
> SEXP edge_update(SEXP D, SEXP Vpair){
> BEGIN_RCPP
> // Translation.
> NumericMatrix xD(D); 
> IntegerVector xVpair(Vpair); 
> xVpair = xVpair-1; 
> for(int i=0; i INDEX IS LOWER THAN 0."); 
> cxx_edge_update(xD,xVpair); 
> return xD;
> END_RCPP
> }//edge.update
> #################################################
> 
> However, when I run it in R, I only get:
> 
> > edge.update(D10,c(0,2))
> Error in edge.update(D10, c(0, 2)) : c++ exception (unknown reason)
> 
> How can I modify my code in order to get the reason for the
> exception printed within R. 
> Thank you very much, 
> 
> -- 
> Cedric Ginestet 
> Centre for Neuroimaging Sciences (L3.04) 
> NIHR Biomedical Research Centre 
> Department of Neuroimaging 
> Institute of Psychiatry, Box P089 
> King's College London 
> De Crespigny Park
> London 
> SE5 8AF 
> Tel: (+44) 20-3228-3052
> Fax: (+44) 20-3228-2116
> Email: cedric.ginestet at kcl.ac.uk
> 
> 
> 



More information about the Rcpp-devel mailing list