[R-pkg-devel] How ton print in the console from Rcpp

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon Nov 14 15:03:24 CET 2022


В Sun, 13 Nov 2022 11:29:21 +0000
Elysée Aristide <ariel92and using gmail.com> пишет:

> The only difference I saw is that all those packages put
> 
> #define NDEBUG
> 
> after #include <RcppArmadillo.h>.
> I did the same thing without understanding :)

Glad you got it working! If you're curious why it helped, see
<https://en.cppreference.com/w/c/error/assert>.

I wouldn't have guessed this to be the problem, because I "knew" that R
CMD INSTALL defines NDEBUG during compilation in order to prevent
assert() from crashing the process. Indeed, it's easy to verify that
RcppArmadillo removes the NDEBUG preprocessor symbol:

https://github.com/RcppCore/RcppArmadillo/search?q=NDEBUG&type=code

Seeing the search results, I can't help but wonder whether Armadillo
still makes any decisions based on this preprocessor definition,
though. Is the whole of Armadillo included as part of the package?
Shouldn't there be other mentions of NDEBUG besides the "#undef NDEBUG"
and the package changelog?

I don't see NDEBUG mentioned in the Armadillo source repo, either:
https://gitlab.com/search?search=NDEBUG&nav_source=navbar&project_id=6604173&search_code=true&repository_ref=11.4.x

Could the #undef NDEBUG line be safely removed now without affecting
the debugging tests performed by Armadillo?

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list