Skip to content

Wrap private module fragment content within conditional extern "C++" - #4083

Merged
vitaut merged 1 commit into
fmtlib:masterfrom
kamrann:pr/extern-private-fragment
Jul 24, 2024
Merged

Wrap private module fragment content within conditional extern "C++"#4083
vitaut merged 1 commit into
fmtlib:masterfrom
kamrann:pr/extern-private-fragment

Conversation

@kamrann

@kamrann kamrann commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

This change fixes some errors generated by clang when building with modules, where it complained that with FMT_ATTACH_TO_GLOBAL_MODULE enabled the private module fragment definitions did not match their declarations.

MSVC did not reject the original code, however I've verified that MSVC is still happy after this change.

@vitaut

vitaut commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

Thanks for the PR. LGTM but could you post the full error (including context) for future reference?

@kamrann

kamrann commented Jul 24, 2024

Copy link
Copy Markdown
Contributor Author

Sure. When compiling on clang 18 with -DFMT_MODULE -DFMT_ATTACH_TO_GLOBAL_MODULE, the following is generated (along with identical errors for many other symbols):

In file included from C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt\src\fmt.cc:131:
In file included from C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt\src\format.cc:8:
C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt/include\fmt/format-inl.h:32:15: error: declaration of 'assert_fail' in module fmt follows declaration in the global module
   32 | FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
      |               ^
C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt/include\fmt\base.h:394:27: note: previous declaration is here
  394 | FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
      |                           ^
In file included from C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt\src\fmt.cc:131:
In file included from C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt\src\format.cc:8:
C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt/include\fmt/format-inl.h:41:15: error: declaration of 'format_error_code' in module fmt follows declaration in the global module
   41 | FMT_FUNC void format_error_code(detail::buffer<char>& out, int error_code,
      |               ^
C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt/include\fmt\format.h:3863:14: note: previous declaration is here
 3863 | FMT_API void format_error_code(buffer<char>& out, int error_code,
      |              ^
In file included from C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt\src\fmt.cc:131:
In file included from C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt\src\format.cc:8:
C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt/include\fmt/format-inl.h:64:15: error: declaration of 'report_error' in module fmt follows declaration in the global module
   64 | FMT_FUNC void report_error(format_func func, int error_code,
      |               ^
C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt/include\fmt\format.h:3867:14: note: previous declaration is here
 3867 | FMT_API void report_error(format_func func, int error_code,
      |              ^

Full command line for reference: C:/LLVM/build-18x/Release/bin/clang++ -DFMT_ATTACH_TO_GLOBAL_MODULE -DFMT_MODULE -IC:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt/include -IC:\Coding\Build2\third-party-packaging\build2-packaging\build\clang-release\fmt -IC:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt -std=c++2b -D__cpp_modules=201907L -Wno-unqualified-std-cast-call -fdiagnostics-color -fansi-escape-codes -finput-charset=UTF-8 -Xclang -fexternc-nounwind -D_MT -D_DLL -Xclang -fmodules-embed-all-files -fmodule-output=..\build\clang-release\fmt\fmt\src\fmt.lib.pcm -o ..\build\clang-release\fmt\fmt\src\fmt.lib.pcm.obj -c -x c++-module C:\Coding\Build2\third-party-packaging\build2-packaging\fmt\fmt\fmt\src\fmt.cc

@vitaut
vitaut merged commit 52b3208 into fmtlib:master Jul 24, 2024
@vitaut

vitaut commented Jul 24, 2024

Copy link
Copy Markdown
Contributor

Merged, thanks!

@kamrann
kamrann deleted the pr/extern-private-fragment branch September 20, 2024 03:33
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