From 02e3f2643f18f67af01e5d3e23149813ccda5af5 Mon Sep 17 00:00:00 2001 From: Bastian de Byl Date: Tue, 12 May 2026 15:40:55 -0400 Subject: [PATCH] fix: drop extern "C" on main to clear -Wpedantic warning src/main.cpp:161:16: warning: cannot declare '::main' with a linkage specification [-Wpedantic] Long-standing upstream OpenInverter code (predates SKUDAK). C++ forbids linkage specifications on main; with -pedantic in CPPFLAGS this fires every build. Confirmed safe to drop: - libopencm3 vector.c:35 forward-declares int main(void) with default linkage and invokes it at boot. - Linker resolves main by symbol name, not by linkage attribute. - stm32-sine has the same upstream issue; same fix applies if we ever push upstream. Bump VERSTR -S3 -> -S4 so the OI web UI version field shows the new build. Verified in the built binary as "4=1.20.R-S4". Build: clean, no compiler warnings (only the long-standing linker RWX notice remains, unrelated). Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitignore | 1 + include/param_prj.h | 4 ++-- src/main.cpp | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index aef8952..db94bea 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ stm32_charger* linker.map *.layout *.out +.DS_Store diff --git a/include/param_prj.h b/include/param_prj.h index c6b113c..15387b5 100644 --- a/include/param_prj.h +++ b/include/param_prj.h @@ -126,9 +126,9 @@ #define CAT_COMM "Communication" // SKUDAK customization suffix: bump on every Skudak-side change so the OpenInverter -// web UI shows a distinct version (e.g. "4=1.20.R-S3") and we can visually confirm +// web UI shows a distinct version (e.g. "4=1.20.R-S4") and we can visually confirm // the right firmware is flashed. Match the stm32-sine -S convention. -#define VERSTR STRINGIFY(4=VER-S3) +#define VERSTR STRINGIFY(4=VER-S4) /***** enums ******/ diff --git a/src/main.cpp b/src/main.cpp index 24ab944..e0214b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -158,7 +158,11 @@ extern "C" void tim2_isr(void) scheduler->Run(); } -extern "C" int main(void) +// C++ forbids a linkage specification on `main` (-Wpedantic). The reset_handler +// in libopencm3's vector.c forward-declares `int main(void)` with default +// linkage and resolves it at link time by symbol name, so dropping `extern "C"` +// here doesn't affect how main is invoked at boot. +int main(void) { extern const TERM_CMD termCmds[];