Skip to content

Commit

Permalink
Add missing inline attributes and include only Rcpp/XPtr.h. (#75)
Browse files Browse the repository at this point in the history
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 <ralf.stubner@gmail.com>
  • Loading branch information
plietar and rstub authored Jan 27, 2024
1 parent 7853a3e commit 6b74223
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion inst/include/dqrng_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <mystdint.h>
#include <stdexcept>
#include <Rcpp/Lightest>
#include <Rcpp/XPtr.h>

namespace dqrng {

Expand Down
4 changes: 2 additions & 2 deletions inst/include/xoshiro.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class xoshiro {
};

template<>
void xoshiro<2>::do_jump(std::array<result_type, 2> JUMP) {
inline void xoshiro<2>::do_jump(std::array<result_type, 2> JUMP) {
uint64_t s0 = 0;
uint64_t s1 = 0;
for(unsigned int i = 0; i < sizeof JUMP / sizeof JUMP.begin(); i++)
Expand All @@ -121,7 +121,7 @@ void xoshiro<2>::do_jump(std::array<result_type, 2> JUMP) {
}

template<>
void xoshiro<4>::do_jump(std::array<result_type, 4> JUMP) {
inline void xoshiro<4>::do_jump(std::array<result_type, 4> JUMP) {
uint64_t s0 = 0;
uint64_t s1 = 0;
uint64_t s2 = 0;
Expand Down

0 comments on commit 6b74223

Please sign in to comment.