-
Notifications
You must be signed in to change notification settings - Fork 60
Fix module-import-in-extern-c compiler error #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Fix module-import-in-extern-c compiler error #557
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 <[email protected]>
3a8f493 to
64b6cf9
Compare
|
Thank you very much for raising and fixing this! Would you mind filing an issue with a description of the problem? That lets people know that it's a known problem and whether it's been fixed already.
We often don't add changelog entries about compiler warnings because compilers are sometimes weirdly picky, and we don't want to create the expectation that we'll treat every warning from every version of every compiler as a bug. But this is a different, as far as I understand: our header files are not compatible with modern C++, it's not just something you can silence with Many of the maintainers of Mbed TLS and TF-PSA-Crypto, me included, are not very familiar with C++. For example, I know you need to put |
Done! Mbed-TLS/mbedtls#10490
I think this actually can be ignored by adding
It looks like simply adding |
Signed-off-by: zacharykeyessonos <[email protected]>
f6def68 to
3724677
Compare
|
Hi @gilles-peskine-arm — Let me know if there are other changes you thing I should make. Thanks! |
Description
This fixes Mbed-TLS/mbedtls#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