Skip to content

Commit

Permalink
Add SPDLOG_TO_VERSION to compare spdlog version (#2853)
Browse files Browse the repository at this point in the history
You can use SPDLOG_VERSION to select the latest spdlog features
where available while falling back to older implementations otherwise.
Using SPDLOG_TO_VERSION() for the value to compare with is recommended.
for Example:
```c++
 void sink_it_(const details::log_msg &msg) override
 {
 #if SPDLOG_VERSION < SPDLOG_TO_VERSION(1,4,0)
     fmt::memory_buffer formatted;
 #else
     memory_buf_t formatted;
 #endif
     sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
     // bala bala...
 }
```
  • Loading branch information
kegechen committed Aug 14, 2023
1 parent 2312489 commit cedfeeb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/spdlog/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
#define SPDLOG_VER_MINOR 12
#define SPDLOG_VER_PATCH 0

#define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH)
#define SPDLOG_TO_VERSION(major, minor, patch) (major * 10000 + minor * 100 + patch)
#define SPDLOG_VERSION SPDLOG_TO_VERSION(SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR, SPDLOG_VER_PATCH)

0 comments on commit cedfeeb

Please sign in to comment.