[Rcpp-devel] Rcpp::stop crashes RGui and RStudio under Windows

Steve Lianoglou mailinglist.honeypot at gmail.com
Fri Nov 30 17:32:49 CET 2012


Hi,

Quick Q:

On Fri, Nov 30, 2012 at 10:20 AM, JJ Allaire <jj.allaire at gmail.com> wrote:
[snip]
> So, we need to investigate how we can prevent exceptions from ever crossing
> DLL boundaries. In the meantime you can use the explicit exception handling
> code that Dirk posted, but of course we are very keen to not have to require
> this boilerplate code on Windows. More later....

It's been a while since I had to go back and dig into my Rcpp code
(hey, it's just working atm ;-), but can't Dirk's example:

// [[Rcpp::export]]
int throwCpp(int nb) {
  try {
    if (nb == 10)
      Rcpp::stop("Unexpected condition occurred");
    return nb*2; // Just for testing the normal case }
  } catch( std::exception &ex ) {
    forward_exception_to_r( ex );
  } catch(...) {
    ::Rf_error( "c++ exception (unknown reason)" );
  }
  return -1; // -Wall
}

still be written like so?

// [[Rcpp::export]]
int throwCpp(int nb) {
BEGIN_RCPP
  if (nb == 10)
    Rcpp::stop("Unexpected condition occurred");
  return nb*2; // Just for testing the normal case }
END_RCPP
}

?

Not so terrible -- especially if you have some Rcpp snippets set up in
your editor of choice, no?

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


More information about the Rcpp-devel mailing list