From 0546dab2e3cb2c8ade75d2eafdb29dece6853608 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 11 May 2021 07:53:32 -0400 Subject: [PATCH] make source location happy on macos * because of course apple doesn't provide any implementation (lmao) we provide one ourself --- llarp/util/logging/source_location.hpp | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/llarp/util/logging/source_location.hpp b/llarp/util/logging/source_location.hpp index f4699b61b..b011a7ede 100644 --- a/llarp/util/logging/source_location.hpp +++ b/llarp/util/logging/source_location.hpp @@ -4,6 +4,69 @@ #include namespace slns = std; #else +#ifdef __APPLE__ +namespace slns +{ + struct source_location + { + public: + static constexpr source_location + current( + const char* fileName = __builtin_FILE(), + const char* functionName = __builtin_FUNCTION(), + const uint_least32_t lineNumber = __builtin_LINE(), + const uint_least32_t columnOffset = __builtin_COLUMN()) noexcept + { + return source_location{fileName, functionName, lineNumber, columnOffset}; + } + + source_location(const source_location&) = default; + source_location(source_location&&) = default; + + constexpr const char* + file_name() const noexcept + { + return fileName; + } + + constexpr const char* + function_name() const noexcept + { + return functionName; + } + + constexpr uint_least32_t + line() const noexcept + { + return lineNumber; + } + + constexpr std::uint_least32_t + column() const noexcept + { + return columnOffset; + } + + private: + constexpr explicit source_location( + const char* fileName, + const char* functionName, + const uint_least32_t lineNumber, + const uint_least32_t columnOffset) noexcept + : fileName(fileName) + , functionName(functionName) + , lineNumber(lineNumber) + , columnOffset(columnOffset) + {} + + const char* fileName; + const char* functionName; + const std::uint_least32_t lineNumber; + const std::uint_least32_t columnOffset; + }; +} // namespace slns +#else #include namespace slns = std::experimental; #endif +#endif