Skip to content

Commit

Permalink
make use of the maybe_unused attribute to suppress compiler issues wi… (
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkreiser committed Jun 13, 2023
1 parent ed93f30 commit d44cd26
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/midgard/logging.cc
@@ -1,6 +1,7 @@
#include "midgard/logging.h"
#include "filesystem.h"

#include <cassert>
#include <chrono>
#include <cstdlib>
#include <ctime>
Expand Down Expand Up @@ -39,8 +40,11 @@ std::string TimeStamp() {
(tp - std::chrono::system_clock::from_time_t(tt)) + std::chrono::seconds(gmt.tm_sec);
// format the string
std::string buffer("year/mo/dy hr:mn:sc.xxxxxx0");
snprintf(&buffer.front(), buffer.length(), "%04d/%02d/%02d %02d:%02d:%09.6f", gmt.tm_year + 1900,
gmt.tm_mon + 1, gmt.tm_mday, gmt.tm_hour, gmt.tm_min, fractional_seconds.count());
[[maybe_unused]] int ret =
snprintf(&buffer.front(), buffer.length(), "%04d/%02d/%02d %02d:%02d:%09.6f",
gmt.tm_year + 1900, gmt.tm_mon + 1, gmt.tm_mday, gmt.tm_hour, gmt.tm_min,
fractional_seconds.count());
assert(ret == static_cast<int>(buffer.length()) - 1);

// Remove trailing null terminator added by snprintf.
buffer.pop_back();
Expand Down

0 comments on commit d44cd26

Please sign in to comment.