[Rcpp-devel] assert() for Rcpp?
Dirk Eddelbuettel
edd at debian.org
Wed Feb 18 18:35:11 CET 2015
On 18 February 2015 at 11:22, Dirk Eddelbuettel wrote:
|
| Hi Kevin,
|
| On 18 February 2015 at 09:02, Kevin Thornton wrote:
| | Hi Dirk,
| |
| | Sorry, but your response is unclear to me. What was "taken care of"? What is 'tinyformat'? Are you trying to say that this method of defining assert will work with any other C++ library that includes <cassert>?
|
| May I suggest you look at the ChangeLog and NEWS files in the git repo, or
| your installed version? They should answer both your questions.
|
| You are claiming breakage with cassert, while not providing a reproducible
| example. See an existence proof below -- hope this helps. It works for me at
| home (Rcpp recent from git) and work (Rcpp current with CRAN).
|
| Dirk
|
| ## Running example
|
| R> library(Rcpp)
| R> sourceCpp("/tmp/kt.cpp")
|
| R> happyNow()
| [1] TRUE
| R>
|
| ## Code below
|
And you also need
#undef NDEBUG here
Dirk
| #include <cassert>
| #include <Rcpp.h>
|
| // [[Rcpp::export]]
| bool happyNow() {
| assert(1 > 0);
| return true;
| }
|
| /*** R
| happyNow()
| */
|
|
|
| |
| | --Kevin
| |
| | > On Feb 18, 2015, at 8:53 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
| | >
| | >
| | > On 18 February 2015 at 08:34, Kevin Thornton wrote:
| | > | Isn't there a potential issue if a package depends on multiple header-only C++ libraries, each of which may include <cassert>? You'd have multiple definitions of the macro floating around, and the compiler will barf.
| | >
| | > Been there, done that -- this whole discussion started because the most
| | > recent Rcpp release had accidentally borked Luke's use of assert (as we
| | > didn't prevent the newly added and hany 'tinyformat' one-header-library from
| | > re-defining assert). (And Kevin also added some other push/pop logic to only
| | > define some other macros when we need them and to generally avoid spillage.)
| | >
| | > So now that this has been taken care of, we are discussing how to provide a
| | > more useful feature "not unlike assert" with proper Rcpp semantics.
| | >
| | > Dirk
| | >
| | > --
| | > http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
| |
| | ___________________________
| | Kevin Thornton
| | Associate Professor
| | Ecology and Evolutionary Biology
| | University of California, Irvine
| | http://www.molpopgen.org
| | http://github.com/molpopgen
| | http://github.com/ThorntonLab
| |
| |
| |
| |
| |
| |
|
| --
| http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list