Fix module-import-in-extern-c compiler error#10488
Open
zacharykeyessonos wants to merge 3 commits intoMbed-TLS:developmentfrom
Open
Fix module-import-in-extern-c compiler error#10488zacharykeyessonos wants to merge 3 commits intoMbed-TLS:developmentfrom
zacharykeyessonos wants to merge 3 commits intoMbed-TLS:developmentfrom
Conversation
This fixes a compiler error when building C++ projects that use the
'modules' C++ language feature consume Mbed TLS. The specific error is
module-import-in-extern-c, which occurs when `#include`s occur within
`extern C` blocks.
```
$ clang-17 -std=c++20 -fmodules -Itf-psa-crypto/include -Itf-psa-crypto/drivers/builtin/include -o sample sample.cpp
In file included from sample.cpp:8:
In file included from tf-psa-crypto/drivers/builtin/include/mbedtls/private/chachapoly.h:44:
tf-psa-crypto/drivers/builtin/include/mbedtls/private/chacha20.h:26:1: error: import of C++ module '_Builtin_stdint' appears within extern "C" language linkage specification [-Wmodule-import-in-extern-c]
26 | #include <stdint.h>
| ^
tf-psa-crypto/drivers/builtin/include/mbedtls/private/chachapoly.h:35:1: note: extern "C" language linkage specification begins here
35 | extern "C" {
| ^
1 error generated.
```
This seems to primarily be an issue with clang. See
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fmodules
Signed-off-by: zacharykeyessonos <zachary.keyes@sonos.com>
This was referenced Oct 31, 2025
Signed-off-by: zacharykeyessonos <zachary.keyes@sonos.com>
Signed-off-by: zacharykeyessonos <zachary.keyes@sonos.com>
79277d4 to
3123f1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This fixes #10490.
This fixes a compiler error when building C++ projects that use the 'modules' C++ language feature consume Mbed TLS. The specific error is module-import-in-extern-c, which occurs when
#includes occur withinextern Cblocks.Example:
This seems to primarily be an issue with clang. See https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fmodules
PR checklist