Skip to content

Move logging.h out of WiFiServer's extern "C" block#5

Merged
thebentern merged 1 commit into
masterfrom
fix-wifiserver-extern-c-logging
Apr 26, 2026
Merged

Move logging.h out of WiFiServer's extern "C" block#5
thebentern merged 1 commit into
masterfrom
fix-wifiserver-extern-c-logging

Conversation

@thebentern

Copy link
Copy Markdown

Summary

WiFiServer.cpp currently does:

extern "C" {
#include "logging.h"
#include "utility/debug.h"
#include "utility/wifi_spi.h"
}

logging.h declares arduino::log(...) in a C++ namespace. With the include inside extern "C" { ... }, that declaration ends up with C linkage and then collides with libc's extern "C" double log(double) from <math.h> — pulled transitively via Arduino.h<memory><cmath>. Apple Clang reports error: conflicting types for 'log' and aborts; Linux GCC silently tolerates the misuse, which is why this never surfaced before.

This PR moves #include "logging.h" outside the extern "C" block (matching the placement that WiFiClient.cpp already uses at line 30) and adds a comment explaining why future edits must not relocate it back inside.

Context

Hit while bringing up the macOS-native portduino build — see firmware PR meshtastic/firmware#10300 for the full bring-up. The other two .cpp files in this library are already correct:

  • WiFiClient.cpp#include "logging.h" is at line 30, after its extern "C" block at line 20–25. No change.
  • WiFiUdp.cpp — does not include logging.h at all. No change.

After this lands

The downstream cleanup chain is:

  1. (this PR) — fix the WiFi submodule.
  2. meshtastic/framework-portduino — bump the libraries/WiFi submodule pointer to the merged commit.
  3. meshtastic/platform-native — bump the framework-portduino git ref in platform.json.
  4. meshtastic/firmware PR #10300 — drop bin/patch-framework-portduino-darwin.py and its extra_scripts entry in [env:native-macos], then bump portduino_base.platform to the new platform-native commit.

Test plan

  • Verified the same byte-level transformation builds meshtasticd cleanly on macOS arm64 (Apple Clang) — the firmware-side pre-build patcher applies the equivalent reordering and the resulting binary boots in SimRadio mode.
  • CI on this repo has no native build target, but the change is syntactic only — no runtime path is added or removed.

🤖 Generated with Claude Code

`logging.h` declares `arduino::log(...)` in a C++ namespace. With it inside
`extern "C" { ... }`, that declaration ends up with C linkage, which then
collides with libc's `extern "C" double log(double)` from <math.h> (pulled
transitively via Arduino.h -> <memory> -> <cmath>). Apple Clang reports it
as `error: conflicting types for 'log'` and aborts; Linux GCC silently
tolerates the misuse, which is why this never surfaced before.

Hit while bringing up the macOS-native portduino build (firmware PR
meshtastic/firmware#10300). The other two cpp files in this library are
already correct: `WiFiClient.cpp` includes logging.h after its extern "C"
block, and `WiFiUdp.cpp` doesn't pull logging.h at all.
@thebentern thebentern merged commit 467ec17 into master Apr 26, 2026
thebentern added a commit to meshtastic/framework-portduino that referenced this pull request Apr 26, 2026
The WiFi submodule's WiFiServer.cpp had `#include "logging.h"` inside an
`extern "C" { ... }` block, which gives `arduino::log(...)` C linkage and
collides with libc's `extern "C" double log(double)` from <math.h> under
Apple Clang ("conflicting types for 'log'"). Fixed in
meshtastic/WiFi#5; this commit bumps the submodule pointer to that change.

Once this is on master, the next steps are: bump platform-native's
framework-portduino pin (meshtastic/platform-native), then drop the
bin/patch-framework-portduino-darwin.py workaround in firmware PR
meshtastic/firmware#10300 and bump platform-native's zip pin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant