Skip to content

Commit 05a1d51

Browse files
committed
reword and extend Rcpp FAQ entry on exceptions across libraries
1 parent d26672c commit 05a1d51

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

vignettes/rmd/Rcpp-FAQ.Rmd

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,8 +1740,17 @@ by the linker, consider running `compileAttributes()` twice. Deleting
17401740

17411741
## Can we use exceptions and stop() across shared libraries?
17421742

1743-
No, sadly. A known limitation coming from the operating system, Windows in
1744-
particular. Exceptions cannot be caught safely as R is statically linked
1745-
with `libgcc` there. Some more background is [in this SO
1743+
Within limits, yes. Code that is generated via Rcpp Attributes (see
1744+
\citet{CRAN:Rcpp:Attributes} and Section~\ref{using-attributes}) generally
1745+
handles this correctly and gracefully via the `try-catch` layer it adds
1746+
shielding the exception from propagating to another, separate dynamic
1747+
library.
1748+
1749+
However, this mechanism relies on dynamic linking with the (system library)
1750+
`libgcc` providing the C++ standard library (as well as on using the same C++
1751+
standard library across all compiled components). But this library is linked
1752+
statically on Windows putting a limitation on the use of `stop()` from within
1753+
Rcpp Modules \citep{CRAN:Rcpp:Modules}. Some more background on the linking
1754+
requirement is [in this SO
17461755
question](https://stackoverflow.com/questions/2424836/exceptions-are-not-caught-in-gcc-program).
17471756

0 commit comments

Comments
 (0)