[R-pkg-devel] CRAN's mysterious behavior building OS/X binaries for OpenMx
Dirk Eddelbuettel
edd @ending from debi@n@org
Tue Sep 25 23:31:19 CEST 2018
On 25 September 2018 at 09:16, Joshua N Pritikin wrote:
| We finally figured out why our binaries were failing to build on OS/X,
| after more than a year of misery.
|
| We use C++ exceptions and try/catch blocks like this,
|
| try {
| // stuff here
| } catch (const std::exception& e) {
|
| This works great with gcc, but whatever version of clang used by CRAN
| doesn't like this code. The exception is not caught. So, instead, we have
| to write
|
| try {
| // stuff here
| } catch (const std::exception& e) {
| // gcc gets here
| } catch (...) {
| // clang gets here
|
| which works on both compilers. I don't know why clang skips the first
| catch clause.
I am not one to quote the C++ standard but for what it is worth, the second
form is that what we have always done in Rcpp land. Witness eg the macro
below inserted by Rcpp Attributes at the end of every function (following on
what we did with inline before Rcpp Attributes), and note the catch-all
block.
Dirk
// There is no return in case of a longjump exception
#ifndef END_RCPP_RETURN_ERROR
#define END_RCPP_RETURN_ERROR \
} \
catch (Rcpp::internal::InterruptedException &__ex__) { \
return Rcpp::internal::interruptedError(); \
} \
catch (Rcpp::LongjumpException& __ex__) { \
return Rcpp::internal::longjumpSentinel(__ex__.token); \
} \
catch (std::exception &__ex__) { \
return exception_to_try_error(__ex__); \
} \
catch (...) { \
return string_to_try_error("c++ exception (unknown reason)"); \
} \
return R_NilValue;
#endif
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org
More information about the R-package-devel
mailing list