Skip to content
Commit d3584b4a authored by Jordan R Abrahams-Whitehead's avatar Jordan R Abrahams-Whitehead Committed by Dan Kalowsky
Browse files

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: default avatarJordan R Abrahams-Whitehead <ajordanr@google.com>
parent 26a2478c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment