Skip to content

avoid include locale inline if c++20 modules are enabled#4451

Merged
vitaut merged 1 commit intofmtlib:masterfrom
arBmind:feature/import-std-locale
May 22, 2025
Merged

avoid include locale inline if c++20 modules are enabled#4451
vitaut merged 1 commit intofmtlib:masterfrom
arBmind:feature/import-std-locale

Conversation

@arBmind
Copy link
Copy Markdown
Contributor

@arBmind arBmind commented May 18, 2025

MSVC hints with:

fmt\include\fmt\format-inl.h(26): warning C5244: '#include <locale>' in the purview of module 'fmt' appears erroneous.  Consider moving that directive before the module declaration, or replace the textual inclusion with 'import <locale>;'.

Then fails the build with type redefinition.

See https://github.com/arBmind/fmtlib-module-experiment for a full example.

Copy link
Copy Markdown
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

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

Please include the error in the PR summary and revert unrelated formatting changes.

@arBmind arBmind force-pushed the feature/import-std-locale branch 2 times, most recently from b8afbf9 to 4057ea8 Compare May 20, 2025 19:48
@arBmind arBmind requested a review from vitaut May 20, 2025 19:50
Comment on lines -25 to -27
#if FMT_USE_LOCALE
# include <locale>
#endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the correct fix is to keep the include here but change the ifdef to

#if !defined(FMT_MODULE) && FMT_USE_LOCALE

MSVC hints with:
```
fmt\include\fmt\format-inl.h(26): warning C5244: '#include <locale>' in the purview of module 'fmt' appears erroneous.  Consider moving that directive before the module declaration, or replace the textual inclusion with 'import <locale>;'.
```

Then fails the build with `type redefinition`.
@arBmind arBmind force-pushed the feature/import-std-locale branch from 4057ea8 to 082da8f Compare May 21, 2025 22:12
@arBmind arBmind requested a review from vitaut May 21, 2025 22:12
@vitaut vitaut merged commit f7033da into fmtlib:master May 22, 2025
45 checks passed
@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented May 22, 2025

Merged, thanks!

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.

2 participants