Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 6b5753242bbcef8e7bc90680cecbe58811a446b9 Mon Sep 17 00:00:00 2001
- From: Tiemo Jung <tiemo.jung@thm.de>
- Date: Sun, 7 Dec 2014 15:16:32 +0100
- Subject: [PATCH] fixed linking errors with multiple translation units
- ---
- include/spdlog/details/format.cc | 38 +++++++++++++++++++-------------------
- include/spdlog/details/format.h | 14 +++++++-------
- 2 files changed, 26 insertions(+), 26 deletions(-)
- diff --git a/include/spdlog/details/format.cc b/include/spdlog/details/format.cc
- index 76ef84e..5c565c3 100644
- --- a/include/spdlog/details/format.cc
- +++ b/include/spdlog/details/format.cc
- @@ -138,7 +138,7 @@ typedef void(*FormatFunc)(fmt::Writer &, int, fmt::StringRef);
- // ERANGE - buffer is not large enough to store the error message
- // other - failure
- // Buffer should be at least of size 1.
- -int safe_strerror(
- +FMT_FUNC int safe_strerror(
- int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT(true) {
- assert(buffer != 0 && buffer_size != 0);
- int result = 0;
- @@ -166,7 +166,7 @@ int safe_strerror(
- return result;
- }
- -void format_error_code(fmt::Writer &out, int error_code,
- +FMT_FUNC void format_error_code(fmt::Writer &out, int error_code,
- fmt::StringRef message) FMT_NOEXCEPT(true) {
- // Report error code making sure that the output fits into
- // INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
- @@ -184,7 +184,7 @@ void format_error_code(fmt::Writer &out, int error_code,
- assert(out.size() <= fmt::internal::INLINE_BUFFER_SIZE);
- }
- -void report_error(FormatFunc func,
- +FMT_FUNC void report_error(FormatFunc func,
- int error_code, fmt::StringRef message) FMT_NOEXCEPT(true) {
- fmt::MemoryWriter full_message;
- func(full_message, error_code, message);
- @@ -232,7 +232,7 @@ inline void require_numeric_argument(const Arg &arg, char spec) {
- }
- template <typename Char>
- -void check_sign(const Char *&s, const Arg &arg) {
- +FMT_FUNC void check_sign(const Char *&s, const Arg &arg) {
- char sign = static_cast<char>(*s);
- require_numeric_argument(arg, sign);
- if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
- @@ -372,7 +372,7 @@ FMT_FUNC void fmt::SystemError::init(
- }
- template <typename T>
- -int fmt::internal::CharTraits<char>::format_float(
- +FMT_FUNC int fmt::internal::CharTraits<char>::format_float(
- char *buffer, std::size_t size, const char *format,
- unsigned width, int precision, T value) {
- if (width == 0) {
- @@ -386,7 +386,7 @@ int fmt::internal::CharTraits<char>::format_float(
- }
- template <typename T>
- -int fmt::internal::CharTraits<wchar_t>::format_float(
- +FMT_FUNC int fmt::internal::CharTraits<wchar_t>::format_float(
- wchar_t *buffer, std::size_t size, const wchar_t *format,
- unsigned width, int precision, T value) {
- if (width == 0) {
- @@ -445,7 +445,7 @@ FMT_FUNC void fmt::internal::report_unknown_type(char code, const char *type) {
- #ifdef _WIN32
- -fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
- +FMT_FUNC fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
- int length = MultiByteToWideChar(
- CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, 0, 0);
- static const char ERROR[] = "cannot convert string from UTF-8 to UTF-16";
- @@ -458,14 +458,14 @@ fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
- FMT_THROW(WindowsError(GetLastError(), ERROR));
- }
- -fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) {
- +FMT_FUNC fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) {
- if (int error_code = convert(s)) {
- FMT_THROW(WindowsError(error_code,
- "cannot convert string from UTF-16 to UTF-8"));
- }
- }
- -int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) {
- +FMT_FUNC int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) {
- int length = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, 0, 0, 0, 0);
- if (length == 0)
- return GetLastError();
- @@ -477,7 +477,7 @@ int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) {
- return 0;
- }
- -void fmt::WindowsError::init(
- +FMT_FUNC void fmt::WindowsError::init(
- int error_code, StringRef format_str, ArgList args) {
- error_code_ = error_code;
- MemoryWriter w;
- @@ -510,7 +510,7 @@ FMT_FUNC void fmt::internal::format_system_error(
- }
- #ifdef _WIN32
- -void fmt::internal::format_windows_error(
- +FMT_FUNC void fmt::internal::format_windows_error(
- fmt::Writer &out, int error_code,
- fmt::StringRef message) FMT_NOEXCEPT(true) {
- class String {
- @@ -623,7 +623,7 @@ public:
- template <typename Char>
- template <typename StrChar>
- -void fmt::BasicWriter<Char>::write_str(
- +FMT_FUNC void fmt::BasicWriter<Char>::write_str(
- const Arg::StringValue<StrChar> &str, const FormatSpec &spec) {
- // Check if StrChar is convertible to Char.
- internal::CharTraits<Char>::convert(StrChar());
- @@ -678,7 +678,7 @@ inline Arg fmt::internal::FormatterBase::get_arg(
- }
- template <typename Char>
- -void fmt::internal::PrintfFormatter<Char>::parse_flags(
- +FMT_FUNC void fmt::internal::PrintfFormatter<Char>::parse_flags(
- FormatSpec &spec, const Char *&s) {
- for (;;) {
- switch (*s++) {
- @@ -705,7 +705,7 @@ void fmt::internal::PrintfFormatter<Char>::parse_flags(
- }
- template <typename Char>
- -Arg fmt::internal::PrintfFormatter<Char>::get_arg(
- +FMT_FUNC Arg fmt::internal::PrintfFormatter<Char>::get_arg(
- const Char *s, unsigned arg_index) {
- const char *error = 0;
- Arg arg = arg_index == UINT_MAX ?
- @@ -716,7 +716,7 @@ Arg fmt::internal::PrintfFormatter<Char>::get_arg(
- }
- template <typename Char>
- -unsigned fmt::internal::PrintfFormatter<Char>::parse_header(
- +FMT_FUNC unsigned fmt::internal::PrintfFormatter<Char>::parse_header(
- const Char *&s, FormatSpec &spec) {
- unsigned arg_index = UINT_MAX;
- Char c = *s;
- @@ -752,7 +752,7 @@ unsigned fmt::internal::PrintfFormatter<Char>::parse_header(
- }
- template <typename Char>
- -void fmt::internal::PrintfFormatter<Char>::format(
- +FMT_FUNC void fmt::internal::PrintfFormatter<Char>::format(
- BasicWriter<Char> &writer, BasicStringRef<Char> format,
- const ArgList &args) {
- const Char *start = format.c_str();
- @@ -923,7 +923,7 @@ void fmt::internal::PrintfFormatter<Char>::format(
- }
- template <typename Char>
- -const Char *fmt::BasicFormatter<Char>::format(
- +FMT_FUNC const Char *fmt::BasicFormatter<Char>::format(
- const Char *&format_str, const Arg &arg) {
- const Char *s = format_str;
- FormatSpec spec;
- @@ -1063,7 +1063,7 @@ const Char *fmt::BasicFormatter<Char>::format(
- }
- template <typename Char>
- -void fmt::BasicFormatter<Char>::format(
- +FMT_FUNC void fmt::BasicFormatter<Char>::format(
- BasicStringRef<Char> format_str, const ArgList &args) {
- const Char *s = start_ = format_str.c_str();
- set_args(args);
- @@ -1090,7 +1090,7 @@ FMT_FUNC void fmt::report_system_error(
- }
- #ifdef _WIN32
- -void fmt::report_windows_error(
- +FMT_FUNC void fmt::report_windows_error(
- int error_code, fmt::StringRef message) FMT_NOEXCEPT(true) {
- report_error(internal::format_windows_error, error_code, message);
- }
- diff --git a/include/spdlog/details/format.h b/include/spdlog/details/format.h
- index 82f6505..77603d5 100644
- --- a/include/spdlog/details/format.h
- +++ b/include/spdlog/details/format.h
- @@ -333,7 +333,7 @@ public:
- };
- template <typename T>
- -void Buffer<T>::append(const T *begin, const T *end)
- +inline void Buffer<T>::append(const T *begin, const T *end)
- {
- std::ptrdiff_t num_elements = end - begin;
- if (size_ + num_elements > capacity_)
- @@ -414,7 +414,7 @@ public:
- };
- template <typename T, std::size_t SIZE, typename Allocator>
- -void MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t size)
- +inline void MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t size)
- {
- std::size_t new_capacity =
- (std::max)(size, this->capacity_ + this->capacity_ / 2);
- @@ -2017,7 +2017,7 @@ BasicWriter<Char>::fill_padding(
- template <typename Char>
- template <typename Spec>
- typename BasicWriter<Char>::CharPtr
- -BasicWriter<Char>::prepare_int_buffer(
- +inline BasicWriter<Char>::prepare_int_buffer(
- unsigned num_digits, const Spec &spec,
- const char *prefix, unsigned prefix_size)
- {
- @@ -2093,7 +2093,7 @@ BasicWriter<Char>::prepare_int_buffer(
- template <typename Char>
- template <typename T, typename Spec>
- -void BasicWriter<Char>::write_int(T value, Spec spec)
- +inline void BasicWriter<Char>::write_int(T value, Spec spec)
- {
- unsigned prefix_size = 0;
- typedef typename internal::IntTraits<T>::MainType UnsignedType;
- @@ -2201,7 +2201,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec)
- template <typename Char>
- template <typename T>
- -void BasicWriter<Char>::write_double(
- +inline void BasicWriter<Char>::write_double(
- T value, const FormatSpec &spec)
- {
- // Check type.
- @@ -2448,7 +2448,7 @@ typedef BasicMemoryWriter<wchar_t> WMemoryWriter;
- // Formats a value.
- template <typename Char, typename T>
- -void format(BasicFormatter<Char> &f, const Char *&format_str, const T &value)
- +inline void format(BasicFormatter<Char> &f, const Char *&format_str, const T &value)
- {
- std::basic_ostringstream<Char> os;
- os << value;
- @@ -2564,7 +2564,7 @@ print(cerr, "Don't {}!", "panic");
- void print(std::ostream &os, StringRef format_str, ArgList args);
- template <typename Char>
- -void printf(BasicWriter<Char> &w, BasicStringRef<Char> format, ArgList args)
- +inline void printf(BasicWriter<Char> &w, BasicStringRef<Char> format, ArgList args)
- {
- internal::PrintfFormatter<Char>().format(w, format, args);
- }
- --
- 1.8.1.msysgit.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement