fix: drop extern "C" on main to clear -Wpedantic warning (-S4) #6

Merged
bastian merged 1 commits from fix/main-extern-c-pedantic-warning into main 2026-05-12 15:41:44 -04:00
Owner

Summary

Eliminates the long-standing pedantic warning Kyle flagged on the bench build:

src/main.cpp:161:16: warning: cannot declare '::main' with a linkage specification [-Wpedantic]

Background

extern "C" int main(void) predates any SKUDAK commit — upstream OpenInverter pattern. C++ forbids linkage specifications on main, and with -pedantic in CPPFLAGS this fires every build.

Fix

Drop the extern "C". Confirmed safe:

  • libopencm3's vector.c:35 forward-declares int main(void) with default linkage and invokes it at boot via symbol-name lookup.
  • The linker resolves main by name, not by linkage attribute.
  • stm32-sine upstream has the same issue — same fix applies if we ever push upstream.

Version bump

VERSTR -S3 → -S4. Verified in the built binary as 4=1.20.R-S4 so Kyle can confirm the right firmware is flashed.

Drive-by

Added .gitignore for macOS .DS_Store files — one snuck into the initial commit on this branch.

Build

Clean, no compiler warnings (only the long-standing linker RWX notice remains, unrelated).

Test plan

  • Flash, OI web UI shows version 4=1.20.R-S4
  • make emits no -Wpedantic warning

🤖 Generated with Claude Code

## Summary Eliminates the long-standing pedantic warning Kyle flagged on the bench build: ``` src/main.cpp:161:16: warning: cannot declare '::main' with a linkage specification [-Wpedantic] ``` ## Background `extern "C" int main(void)` predates any SKUDAK commit — upstream OpenInverter pattern. C++ forbids linkage specifications on `main`, and with `-pedantic` in CPPFLAGS this fires every build. ## Fix Drop the `extern "C"`. Confirmed safe: - libopencm3's `vector.c:35` forward-declares `int main(void)` with default linkage and invokes it at boot via symbol-name lookup. - The linker resolves `main` by name, not by linkage attribute. - `stm32-sine` upstream has the same issue — same fix applies if we ever push upstream. ## Version bump `VERSTR` `-S3 → -S4`. Verified in the built binary as `4=1.20.R-S4` so Kyle can confirm the right firmware is flashed. ## Drive-by Added `.gitignore` for macOS `.DS_Store` files — one snuck into the initial commit on this branch. ## Build Clean, no compiler warnings (only the long-standing linker RWX notice remains, unrelated). ## Test plan - [ ] Flash, OI web UI shows version `4=1.20.R-S4` - [ ] `make` emits no `-Wpedantic` warning 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bastian added 1 commit 2026-05-12 15:41:28 -04:00
fix: drop extern "C" on main to clear -Wpedantic warning
Build Firmware / Build stm32-teslacharger (pull_request) Successful in 1m1s
02e3f2643f
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) <noreply@anthropic.com>
bastian merged commit e36ba2ccc5 into main 2026-05-12 15:41:44 -04:00
bastian deleted branch fix/main-extern-c-pedantic-warning 2026-05-12 15:41:44 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Skudak/stm32-openinverter-teslacharger#6