3# Copyright (C) 2009 - 2010 Romain Francois and Dirk Eddelbuettel
5# This file is part of Rcpp.
7# Rcpp is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 2 of the License, or
10# (at your option) any later version.
12# Rcpp is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
17# You should have received a copy of the GNU General Public License
18# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
23## NOTE: This is the old way to compile Rcpp code inline.
24## The code here has left as a historical artifact and tribute to the old way.
25## Please use the code under the "new" inline compilation section.
28funx_old <- cxxfunction(
30 'throw std::range_error("boom"); return R_NilValue ; ',
33## NOTE: Within this section, the new way to compile Rcpp code inline has been
34## written. Please use the code next as a template for your own project.
38 throw std::range_error("boom"); return R_NilValue ;
41tryCatch( funx(), "C++Error" = function(e){
42 cat( sprintf( "C++ exception of class '%s' : %s\n", class(e)[1L], e$message ) )
44# or using a direct handler
45tryCatch( funx(), "std::range_error" = function(e){
46 cat( sprintf( "C++ exception of class '%s' : %s\n", class(e)[1L], e$message ) )
48# just to check things carry on