From 6b74223b2011843002c25d6a63a26b4eca2ababa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Li=C3=A9tar?= Date: Sat, 27 Jan 2024 18:10:23 +0000 Subject: [PATCH] Add missing inline attributes and include only Rcpp/XPtr.h. (#75) The `xoshiro<2>::do_jump` specializations need some `inline` attribute, otherwise including dqrng from multiple compilation units causes linker errors due to symbols being defined multiple times. --------- Co-authored-by: Ralf Stubner --- NEWS.md | 1 + inst/include/dqrng_types.h | 2 +- inst/include/xoshiro.h | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0554609..8d452cb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * The default RNG has changed from Xoroshiro128+ to Xoroshiro128++. The older generators Xoroshiro128+ and Xoshiro256+ are still available but should only be used for backward compatibility or for generating floating point numbers, i.e. not sampling etc. ([#57](https://github.com/daqana/dqrng/pull/57) fixing [#56](https://github.com/daqana/dqrng/issues/56)) * The `dqrng::rng64_t` type has been changed to use `Rcpp::XPtr` instead of `std::shared_ptr` and the functions from `dqrng_sample.h` now expect a reference to `dqrng::random_64bit_generator` instead of `dqrng::rng64_t` ([#70](https://github.com/daqana/dqrng/pull/70) fixing [#63](https://github.com/daqana/dqrng/issues/63)) +* Add missing inline attributes and limit the included Rcpp headers in `dqrng_types.h` ([#75](https://github.com/daqana/dqrng/pull/75) together with Paul LiƩtar) ## Other changes diff --git a/inst/include/dqrng_types.h b/inst/include/dqrng_types.h index bc0aad4..6d19c21 100644 --- a/inst/include/dqrng_types.h +++ b/inst/include/dqrng_types.h @@ -22,7 +22,7 @@ #include #include -#include +#include namespace dqrng { diff --git a/inst/include/xoshiro.h b/inst/include/xoshiro.h index d03e7f9..debf9ce 100644 --- a/inst/include/xoshiro.h +++ b/inst/include/xoshiro.h @@ -104,7 +104,7 @@ class xoshiro { }; template<> -void xoshiro<2>::do_jump(std::array JUMP) { +inline void xoshiro<2>::do_jump(std::array JUMP) { uint64_t s0 = 0; uint64_t s1 = 0; for(unsigned int i = 0; i < sizeof JUMP / sizeof JUMP.begin(); i++) @@ -121,7 +121,7 @@ void xoshiro<2>::do_jump(std::array JUMP) { } template<> -void xoshiro<4>::do_jump(std::array JUMP) { +inline void xoshiro<4>::do_jump(std::array JUMP) { uint64_t s0 = 0; uint64_t s1 = 0; uint64_t s2 = 0;