Skip to content

Commit ae9cd85

Browse files
committed
add on switch
1 parent 6b326a6 commit ae9cd85

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

inst/include/Rcpp/macros/mask.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
#define Rcpp_macros_mask_h
2222

2323
#ifndef RCPP_NO_MASK_RF_ERROR
24-
/** cannot emit a message, no warning yet
24+
#ifdef RCPP_MASK_RF_ERROR
2525
#define Rf_error(...) \
2626
_Pragma("GCC warning \"Use of Rf_error() instead of Rcpp::stop(). Calls \
2727
to Rf_error() in C++ contexts are unsafe: consider using Rcpp::stop() instead, \
2828
or define RCPP_NO_MASK_RF_ERROR if this is a false positive. More info:\n\
2929
- https://github.com/RcppCore/Rcpp/issues/1247\n\
3030
- https://github.com/RcppCore/Rcpp/pull/1402\"") \
3131
Rf_error(__VA_ARGS__)
32-
**/
32+
#endif
3333
#endif
3434

3535
#endif

test.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <Rcpp.h>
2+
using namespace Rcpp;
3+
4+
struct A {
5+
A() { Rprintf("A()\n"); }
6+
~A() { Rprintf("~A()\n"); }
7+
};
8+
9+
// [[Rcpp::export]]
10+
void uhoh() {
11+
A a;
12+
Rprintf("Before error\n");
13+
:: Rf_error("%s: %d", "asdf", 3);
14+
}
15+
16+
/*** R
17+
uhoh()
18+
*/

0 commit comments

Comments
 (0)