Coder Social home page Coder Social logo

Comments (7)

tt4g avatar tt4g commented on June 11, 2024

spdlog does not recognize that the compiler supports std::format_string, so it uses std::string_view as the format argument.

#ifdef SPDLOG_USE_STD_FORMAT
namespace fmt_lib = std;
using string_view_t = std::string_view;
using memory_buf_t = std::string;
template <typename... Args>
#if __cpp_lib_format >= 202207L
using format_string_t = std::format_string<Args...>;
#else
using format_string_t = std::string_view;
#endif

C++23 is required because std::format_string is a C++23 feature.
I think you have not enabled it with compiler flags.

from spdlog.

sfulham avatar sfulham commented on June 11, 2024

Thanks @tt4g, it seems as if, even with c++23 set, __cpp_lib_format is set to 202106 with libstdc++13.1 and undefined with libc++-17. I'm on PopOS 22.04 so some packages may be a little behind, but these are the latest packages I can seem to find.

from spdlog.

sfulham avatar sfulham commented on June 11, 2024

It seems if I manually define __cpp_lib_format to 202207L with libc++-17 it works fine, however this is really not a permanent solution.

from spdlog.

tt4g avatar tt4g commented on June 11, 2024

__cpp_lib_format >= 202207L should be a prerequisite for std::format_string support.

See __cpp_lib_format section in Feature testing - cppreference.com and P2508R1.

The fact that it is 202106 means that the compiler does not support std::format_string, so using std::format_string in Log::PrintMessage is a mistake.

from spdlog.

tt4g avatar tt4g commented on June 11, 2024

It seems if I manually define __cpp_lib_format to 202207L with libc++-17 it works fine, however this is really not a permanent solution.

If so, it may be a compiler bug.
Please report it to the compiler maintainer.

from spdlog.

sfulham avatar sfulham commented on June 11, 2024

It seems if I manually define __cpp_lib_format to 202207L with libc++-17 it works fine, however this is really not a permanent solution.

If so, it may be a compiler bug. Please report it to the compiler maintainer.

After some more digging, it seems it isn't a mistake/it is known to be undefined, https://libcxx.llvm.org/FeatureTestMacroTable.html

from spdlog.

tt4g avatar tt4g commented on June 11, 2024

spdlog cannot use the feature that the compiler does not support.
You should not use std::format_string.

from spdlog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.