misc: Restrict linkage for main to freestanding
`extern "C"` is not a valid language linkage for declaring `int main(...)`, as per the ISO C++ Standard Specification. This fixes the violations of -Wmain, and brings Zephyr closer to valid C++. See the C++ standard wording here: https://eel.is/c++draft/basic.start.main#3.sentence-5 See also the clang warning -Wmain: https://clang.llvm.org/docs/DiagnosticsReference.html#wmain However, for freestanding code (i.e. with -ffreestanding), main has no special meaning, and we need to prevent name mangling. So allow this forward linkage when not hosted. This only applies to C++ as these linkage declarations only exist inside __cplusplus guards. Signed-off-by:Jordan R Abrahams-Whitehead <ajordanr@google.com>
Loading
Please sign in to comment