Skip to content

Commit ff4fc8b

Browse files
committed
test: compile idle_state.h against Arduino's macro namespace
Companion to the HiveHub fix. These host tests build the pure headers against a bare compiler, where Arduino's few hundred all-caps macros do not exist — so a constant in the shared counter_protocol.h that collides with one of them passes every check here and fails only in the firmware build. HiveHub hit exactly that with an enumerator named DISABLED meeting esp32-hal-gpio.h's `#define DISABLED 0x00`. Define the macros that actually bite before the include, so the collision surfaces in seconds on a host compiler instead of partway through a firmware build. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016gFpezSuXW3sHMd1xaSYnd
1 parent 281e5ad commit ff4fc8b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Firmware/test/test_idle_state/test_idle_state.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@
1616
// or via test/run_tests.sh, which builds every host test.
1717
// ============================================================================
1818

19+
// ---------------------------------------------------------------------------
20+
// Arduino's macro soup, reproduced before the include on purpose.
21+
// ---------------------------------------------------------------------------
22+
// idle_state.h and counter_protocol.h are built two ways: here, against a bare
23+
// host compiler, and in the firmware, after Arduino.h has defined a few hundred
24+
// all-caps macros. The second is far more hostile, and a test that only sees
25+
// the first cannot catch a name collision — HiveHub hit exactly that, where an
26+
// enumerator named DISABLED met esp32-hal-gpio.h's `#define DISABLED 0x00` and
27+
// broke the build while every host check passed.
28+
//
29+
// So define the ones that actually bite, with their real Arduino values, before
30+
// the include. Any constant added to the shared protocol header that strays
31+
// into the all-caps macro namespace now fails on a host compiler in seconds
32+
// rather than partway through a firmware build. Deliberately NOT #undef'd.
33+
#define DISABLED 0x00
34+
#define INPUT 0x01
35+
#define OUTPUT 0x03
36+
#define PULLUP 0x04
37+
#define PULLDOWN 0x08
38+
#define HIGH 0x1
39+
#define LOW 0x0
40+
#define ANALOG 0xC0
41+
#define OPEN_DRAIN 0x10
42+
1943
#include "idle_state.h"
2044

2145
#include <cstdio>

0 commit comments

Comments
 (0)