Cannot build stb_image when spdlog is imported from the precompiled header #1432
-
#1258 Is there any way to fix this? I'm using the latest version of stb_image and using the latest commit of spdlog's |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
This looks like I don't understand why the file setting Just make sure that the .c/.cpp file (or other translation unit) that defines STB_IMAGE_IMPLEMENTATION doesn't include spdlog.h. There's no reason to, and if you don't include both they're not going to clash. |
Beta Was this translation helpful? Give feedback.
-
As said before, this is almost certainly a preprocessor macro problem, if you want to get to the bottom of this you'll need to look at the preprocessed source. Which header file it materializes in is almost certainly completely immaterial. |
Beta Was this translation helpful? Give feedback.
-
I don't know. None of that's us either, maybe ask the GCC folks? |
Beta Was this translation helpful? Give feedback.
-
The problem comes from fmt library that is bundled with spdlog: https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h#L287 Kind of related gcc bug here: https://gcc.gnu.org/bugzilla//show_bug.cgi?id=105120 One workaround would be to put |
Beta Was this translation helpful? Give feedback.
The problem comes from fmt library that is bundled with spdlog: https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h#L287
This line enables optimization - so any code included afterwards will work as if __OPTIMIZE__ define is set. This makes your precompiled header be created with __OPTIMIZE__ define. Even for "debug" builds. But when you compile actual code then optimizations are not enabled and _mm_slli_si128 intrinsic will not be able to work (no inlining) as it is defined as inline function when __OPTIMIZE__ is enabled.
Kind of related gcc bug here: https://gcc.gnu.org/bugzilla//show_bug.cgi?id=105120
One workaround would be to put
#define FMT_GCC_PRAGMA(...)
inside your pch.h…