gabime / spdlog

Fast C++ logging library.
Other
24.57k stars 4.58k forks source link

Static assertion fails: formatting non-void pointers is not allowed #3270

Closed Animus-Surge closed 4 days ago

Animus-Surge commented 5 days ago

Trying to build a project with spdlog using cmake and gnu make results in the following assertion error:

error: static assertion failed: Formatting of non-void pointers is disallowed.
1635 |   static_assert(formattable_pointer,
     |
note: `formattable_pointer` evaluates to false

I have never used spdlog before and therefore have no idea what I am doing wrong, if anything.

I tried two different methods for adding spdlog to my project:

FetchContent_Declare(
    spdlog
    GIT_REPOSITORY https://github.com/gabime/spdlog.git
    GIT_TAG v1.15.0
)
FetchContent_MakeAvailable(spdlog)

#...

target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog)

Currently I use the latter, but both result in the same error. Is there any guidance on something like this? I looked through the issues list but I couldn't find anything that matched.

Versions: spdlog v1.15.0 cmake 3.25.1 gnu make 4.3

tt4g commented 4 days ago

Duplicate: #2527, #1492

Wrap fmt::ptr() to pointer variable.

If you encounter assertion errors, could you also provide us with the source code of your project that caused the error? It will help us to investigate the cause of the error.

Animus-Surge commented 4 days ago

That worked, thank you.

Is there a documentation page that describes these quirks somewhere? My use case was calling a function that returned a char* and there wasn't any info in the readme about that.

tt4g commented 4 days ago

The logging format is implemented by the fmt library:

https://github.com/gabime/spdlog/blob/951c5b9987e21e74ad052593e56bcba89911ef80/README.md?plain=1#L48

You need to read the documentation of the fmt library.

fmtlib/fmt:

Animus-Surge commented 4 days ago

I see, thank you.