Skip to content

Commit

Permalink
Ensure individual version matches what was compiled against.
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Sep 6, 2024
1 parent 83375fe commit 4a53b3a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ fast_weighted_sample <- function(size, probs) {
.Call(`_malariasimulation_fast_weighted_sample`, size, probs)
}

individual_headers_version <- function() {
.Call(`_malariasimulation_individual_headers_version`)
}

13 changes: 13 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.onLoad <- function(libname, pkgname){
headers_version <- individual_headers_version()
package_version <- as.character(packageVersion("individual"))
if (!identical(package_version, headers_version)) {
warning(sprintf(paste(
"malariasimulation was compiled against version '%s' of the individual,",
"but version '%s' is currently loaded. This is likely to cause,",
"malariasimulation to misbehave. You should re-install",
"malariasimulation. If using devtools, run `devtools::clean_dll` and",
"then load malariasimulation again."
), headers_version, package_version))
}
}
11 changes: 11 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// individual_headers_version
std::string individual_headers_version();
RcppExport SEXP _malariasimulation_individual_headers_version() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(individual_headers_version());
return rcpp_result_gen;
END_RCPP
}

RcppExport SEXP run_testthat_tests(void);

Expand Down Expand Up @@ -377,6 +387,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_malariasimulation_bernoulli_multi_p_cpp", (DL_FUNC) &_malariasimulation_bernoulli_multi_p_cpp, 1},
{"_malariasimulation_bitset_index_cpp", (DL_FUNC) &_malariasimulation_bitset_index_cpp, 2},
{"_malariasimulation_fast_weighted_sample", (DL_FUNC) &_malariasimulation_fast_weighted_sample, 2},
{"_malariasimulation_individual_headers_version", (DL_FUNC) &_malariasimulation_individual_headers_version, 0},
{"run_testthat_tests", (DL_FUNC) &run_testthat_tests, 0},
{NULL, NULL, 0}
};
Expand Down
5 changes: 5 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ Rcpp::IntegerVector fast_weighted_sample(
values = values + 1;
return values;
}

//[[Rcpp::export]]
std::string individual_headers_version() {
return INDIVIDUAL_VERSION;
}

0 comments on commit 4a53b3a

Please sign in to comment.