Skip to content

Fix issue #236: drop FMT_STRING wrappers in ColourSpace example#237

Merged
garyo merged 2 commits into
AcademySoftwareFoundation:mainfrom
garyo:fix/issue-236-fmt-string
Apr 24, 2026
Merged

Fix issue #236: drop FMT_STRING wrappers in ColourSpace example#237
garyo merged 2 commits into
AcademySoftwareFoundation:mainfrom
garyo:fix/issue-236-fmt-string

Conversation

@garyo
Copy link
Copy Markdown
Contributor

@garyo garyo commented Apr 20, 2026

spdlog since around 1.8 doesn't need FMT_STRING anymore, and it may cause type errors when used on plain strings with no format specs.

@garyo garyo requested review from barretpj and jfpanisset April 20, 2026 11:17
@barretpj
Copy link
Copy Markdown
Contributor

It's needed for any compilation using C++17 or older, which includes my build environment.

@garyo
Copy link
Copy Markdown
Contributor Author

garyo commented Apr 20, 2026

Interesting. I tried a bunch of compiler/OS/fmt/spdlog versions yesterday and couldn't make it fail without it, so please send the exact setup and I'll make sure that's tested and we'll add checks for it.

@barretpj
Copy link
Copy Markdown
Contributor

This is building the examples inside our Baselight makefile-based build, not using cmake or other build systems.

@barretpj
Copy link
Copy Markdown
Contributor

barretpj commented Apr 20, 2026

Specifically, gcc 11.5, fmt{} 11.1.4, -std:c++17

@jfpanisset
Copy link
Copy Markdown

Here's what I ran into:

#236

With g++ 14.2.1, compiling either C++17 or C++20, using spdlog 1.5.1 or 1.7.0, with either the embedded fmt version or the corresponding, external fmt, the compiler rejects calls to spdlog::info(FMT_STRING("a simple string")) without variable interpolation (it compiles fine when the string contains "{}" and extra variables are passed). The error complains about an incomplete type during template instantiation.

RIght now I'm having to override FMT_STRING():

#if 1
#define FMT_STRING(x) x
#endif

but of course the compiler complains. We could either try to figure out the specific compiler versions which have issues with this and #ifdef appropriately, or use our own OFX_FMT_STRING() macro so it can be easily #ifdef'd away without having to re-define the existing one?

@garyo
Copy link
Copy Markdown
Contributor Author

garyo commented Apr 20, 2026

Thanks for these notes, folks — I'll look into this and come up with a proper fix.

garyo added a commit to garyo/openfx that referenced this pull request Apr 21, 2026
…COMPILE_STRING

Some downstream projects (e.g. Baselight) opt in to fmt's strict
compile-string check via -DFMT_ENFORCE_COMPILE_STRING. In C++17 that
flag rejects any format string that isn't wrapped in FMT_STRING, which
broke the unwrapped calls from AcademySoftwareFoundation#237. At the same time, wrapping
zero-arg spdlog calls in FMT_STRING was what triggered the original
failure in AcademySoftwareFoundation#236 (old spdlog's SFINAE couldn't handle the compile-time
type when there were no placeholders).

The wrapper expands to FMT_STRING only when the fmt strict flag is
set *and* fmt itself can't consteval-check (so C++20+ and modern fmt
just get plain strings). It's only applied at callsites that pass
format args; zero-arg spdlog::info("msg") takes a string_view overload
that bypasses fmt's format_string machinery entirely, so those sites
are left alone and AcademySoftwareFoundation#236's failure pattern stays avoided.

Also adds a Makefile for ColourSpace (was missing; not in Examples
SUBDIRS either) and a CI matrix entry "Linux Rocky 8 VFX CY2023 strict
fmt" that builds with -DFMT_ENFORCE_COMPILE_STRING, so any future
example that adopts spdlog without OFX_FMT_STRING trips the build.
The new entry sets skip_release_upload so it doesn't produce extra
release artifacts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@jfpanisset jfpanisset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you actually went to the bottom of this!

BTW I'm about to release updated aswf-docker images, including an update to the 2023 images (which had not been updated in a long time since the transition of 2024/25/26 to Conan 2), I've verified that it builds against OpenFX 1.5s, but not latest. Will be good to test.

@garyo
Copy link
Copy Markdown
Contributor Author

garyo commented Apr 21, 2026

Yeah, took a few tries (Claude helps a lot with this, spinning up containers, trying things quickly). But I think this is a complete solution. I wish that macro weren't needed at all, but for older compilers/fmt versions it looks like it is.

garyo added 2 commits April 21, 2026 14:12
…ColourSpace example

Signed-off-by: Gary Oberbrunner <garyo@darkstarsystems.com>
…COMPILE_STRING

Some downstream projects (e.g. Baselight) opt in to fmt's strict
compile-string check via -DFMT_ENFORCE_COMPILE_STRING. In C++17 that
flag rejects any format string that isn't wrapped in FMT_STRING, which
broke the unwrapped calls from AcademySoftwareFoundation#237. At the same time, wrapping
zero-arg spdlog calls in FMT_STRING was what triggered the original
failure in AcademySoftwareFoundation#236 (old spdlog's SFINAE couldn't handle the compile-time
type when there were no placeholders).

The wrapper expands to FMT_STRING only when the fmt strict flag is
set *and* fmt itself can't consteval-check (so C++20+ and modern fmt
just get plain strings). It's only applied at callsites that pass
format args; zero-arg spdlog::info("msg") takes a string_view overload
that bypasses fmt's format_string machinery entirely, so those sites
are left alone and AcademySoftwareFoundation#236's failure pattern stays avoided.

Also adds a Makefile for ColourSpace (was missing; not in Examples
SUBDIRS either) and a CI matrix entry "Linux Rocky 8 VFX CY2023 strict
fmt" that builds with -DFMT_ENFORCE_COMPILE_STRING, so any future
example that adopts spdlog without OFX_FMT_STRING trips the build.
The new entry sets skip_release_upload so it doesn't produce extra
release artifacts.

Signed-off-by: Gary Oberbrunner <garyo@darkstarsystems.com>
@garyo garyo force-pushed the fix/issue-236-fmt-string branch from 884eb45 to b350155 Compare April 21, 2026 18:15
@garyo garyo merged commit 1b74e43 into AcademySoftwareFoundation:main Apr 24, 2026
10 checks passed
@garyo garyo deleted the fix/issue-236-fmt-string branch April 24, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants