Skip to content

Commit

Permalink
fix windows error with Jim (#215)
Browse files Browse the repository at this point in the history
Co-authored-by: Jim Hester <james.f.hester@gmail.com>
  • Loading branch information
sbearrows and jimhester committed Jul 27, 2021
1 parent b9ec7eb commit 087861f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions inst/include/cpp11/function.hpp
Expand Up @@ -75,23 +75,24 @@ class package {
SEXP data_;
};

static auto R_message = cpp11::package("base")["message"];

#ifdef CPP11_USE_FMT
template <typename... Args>
void message(const char* fmt_arg, Args... args) {
static auto R_message = cpp11::package("base")["message"];
std::string msg = fmt::format(fmt_arg, args...);
R_message(msg.c_str());
}

template <typename... Args>
void message(const std::string& fmt_arg, Args... args) {
static auto R_message = cpp11::package("base")["message"];
std::string msg = fmt::format(fmt_arg, args...);
R_message(msg.c_str());
}
#else
template <typename... Args>
void message(const char* fmt_arg, Args... args) {
static auto R_message = cpp11::package("base")["message"];
char buff[1024];
int msg = std::snprintf(buff, 1024, fmt_arg, args...);
if (msg >= 0 && msg < 1024) {
Expand All @@ -101,6 +102,7 @@ void message(const char* fmt_arg, Args... args) {

template <typename... Args>
void message(const std::string& fmt_arg, Args... args) {
static auto R_message = cpp11::package("base")["message"];
char buff[1024];
int msg = std::snprintf(buff, 1024, fmt_arg.c_str(), args...);
if (msg >= 0 && msg < 1024) {
Expand Down

0 comments on commit 087861f

Please sign in to comment.