Skip to content

Commit

Permalink
Accomodate format string warnings under r-devel
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Nov 30, 2023
1 parent dc6e2ee commit 7431712
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2023-11-30 Dirk Eddelbuettel <edd@debian.org>

* inst/include/tidy/internals.h: Accomodate -Wformat
-Wformat-security warnings under R-devel by adding format string

* tests/version.R: Add a test for consistent inst/NEWS.Rd versioning

* .github/workflows/ci.yaml (jobs): Update to actions/checkout@v4
Expand Down
12 changes: 11 additions & 1 deletion inst/include/tidy/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// internals.h: tidying some parts of Rinternals.h

// Copyright (C) 2020 - 2021 Dirk Eddelbuettel
// Copyright (C) 2020 - 2023 Dirk Eddelbuettel
//
// This file is part of tidyCpp
//
Expand Down Expand Up @@ -104,9 +104,19 @@ namespace R { // we remain all tidied up in a namespace
// cf R_ext/Error.h
template <typename... Args>
inline void error(const char *msg, Args... args) { Rf_error(msg, args...); }
// Version above tickles R-devel warning for format string, need to unroll Args... here.
// Can be used with
// template <typename... Args>
// inline void errro(const char* fmt, Args&&... args ) {
// Rf_error("%s", tfm::format(fmt, std::forward<Args>(args)... ).c_str());
// if tinyformat headers are available (as in Rcpp)
// Version below is an alternative for pre-formed strings
inline void error(const char *msg) { Rf_error("%s", msg); }

template <typename... Args>
inline void warning(const char *msg, Args... args) { Rf_warning(msg, args...); }
// See error() above, same comment applies here
inline void warning(const char *msg) { Rf_warning("%s", msg); }

inline void message(const char *s) { R_ShowMessage(s); }

Expand Down

0 comments on commit 7431712

Please sign in to comment.