fixed src_location namings and added macros for msvc

pull/2690/head
M. Galib Uludag 2 years ago
parent fd995f4c51
commit 1d24268488

@ -112,18 +112,12 @@
catch (const std::exception &) {}
#endif
#ifdef _MSC_VER
#define SPDLOG_CPLUSPLUS _MSVC_LANG
#else
#define SPDLOG_CPLUSPLUS __cplusplus
#endif
#if SPDLOG_CPLUSPLUS > 201703L
#define SPDLOG_CONSTEVAL consteval
# define SPDLOG_CONSTEVAL consteval
#elif SPDLOG_CPLUSPLUS < 201402L
#define SPDLOG_CONSTEVAL
# define SPDLOG_CONSTEVAL
#else
#define SPDLOG_CONSTEVAL constexpr
# define SPDLOG_CONSTEVAL constexpr
#endif
namespace spdlog {
@ -167,11 +161,6 @@ struct format_string_wrapper
: fmt_{fmtstr}
, loc_{loc}
{}
#elif !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION < 80000
SPDLOG_CONSTEXPR format_string_wrapper(const Char* fmtstr, details::source_location loc = details::source_location::current())
: fmt_{fmtstr}
, loc_{loc}
{}
#else
template <typename S>
requires std::is_convertible_v<S, T>

@ -4,8 +4,14 @@
#include <cstdint>
#ifdef _MSC_VER
# define SPDLOG_CPLUSPLUS _MSVC_LANG
#else
# define SPDLOG_CPLUSPLUS __cplusplus
#endif
#ifdef __has_include
# if __has_include(<source_location>) && __cplusplus >= 202002L
# if __has_include(<source_location>) && SPDLOG_CPLUSPLUS >= 202002L
# include <source_location>
# define SPDLOG_SOURCE_LOCATION
# endif
@ -23,57 +29,57 @@ public:
#if !defined(__apple_build_version__) && defined(__clang__) && \
(__clang_major__ >= 9)
static constexpr source_location
current(const char *fileName = __builtin_FILE(),
const unsigned lineNumber = __builtin_LINE(),
const char *functionName = __builtin_FUNCTION(),
const unsigned columnOffset = __builtin_COLUMN()) noexcept
current(const char *file = __builtin_FILE(),
const unsigned line = __builtin_LINE(),
const char *function = __builtin_FUNCTION(),
const unsigned column = __builtin_COLUMN()) noexcept
#elif defined(__GNUC__) && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
static constexpr source_location
current(const char *fileName = __builtin_FILE(),
const unsigned lineNumber = __builtin_LINE(),
const char *functionName = __builtin_FUNCTION(),
const unsigned columnOffset = 0) noexcept
current(const char *file = __builtin_FILE(),
const unsigned line = __builtin_LINE(),
const char *function = __builtin_FUNCTION(),
const unsigned column = 0) noexcept
#elif defined(_MSC_VER) && (_MSC_VER > 1925)
static constexpr source_location
current(const char *fileName = __builtin_FILE(),
const unsigned lineNumber = __builtin_LINE(),
const char *functionName = __builtin_FUNCTION(),
const unsigned columnOffset = __builtin_COLUMN()) noexcept
current(const char *file = __builtin_FILE(),
const unsigned line = __builtin_LINE(),
const char *function = __builtin_FUNCTION(),
const unsigned column = __builtin_COLUMN()) noexcept
#else
static constexpr source_location
current(const char *fileName = "unsupported",
const unsigned lineNumber = 0,
const char *functionName = "unsupported",
const unsigned columnOffset = 0) noexcept
current(const char *file = nullptr,
const unsigned line = 0,
const char *function = nullptr,
const unsigned column = 0) noexcept
#endif
{
return source_location(fileName, lineNumber, functionName, columnOffset);
return source_location(file, line, function, column);
}
source_location(const source_location &) = default;
source_location(source_location &&) = default;
constexpr const char *file_name() const noexcept { return fileName; }
constexpr const char *file_name() const noexcept { return file_; }
constexpr const char *function_name() const noexcept { return functionName; }
constexpr const char *function_name() const noexcept { return function_; }
constexpr unsigned line() const noexcept { return lineNumber; }
constexpr unsigned line() const noexcept { return line_; }
constexpr unsigned column() const noexcept { return columnOffset; }
constexpr unsigned column() const noexcept { return column_; }
private:
constexpr source_location(const char *fileName,
const unsigned lineNumber,
const char *functionName,
const unsigned columnOffset) noexcept
: fileName(fileName), lineNumber(lineNumber), functionName(functionName),
columnOffset(columnOffset) {}
constexpr source_location(const char *file,
const unsigned line,
const char *function,
const unsigned column) noexcept
: file_(file), line_(line), function_(function),
column_(column) {}
const char *fileName;
const unsigned lineNumber;
const char *functionName;
const unsigned columnOffset;
const char *file_;
const unsigned line_;
const char *function_;
const unsigned column_;
};
} // namespace details
} // namespace spdlog

Loading…
Cancel
Save