Skip to content

Commit 698ad5d

Browse files
committed
HardwareSerial: Define no-op serialEvent() functions for clang
GCC automatically resolves weakly defined empty symbols to null if not overridden, but Clang doesn't resolve it this way. This causes undefined reference errors during linking. To address this, define empty no-op serialEvent() functions that can be overridden later since its weakly defined, ensuring compatibility with Clang and fixing the build issue. ref: avr-llvm/clang#9 Signed-off-by: Dakkshesh <[email protected]>
1 parent c8c514c commit 698ad5d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: cores/arduino/HardwareSerial.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,33 @@
4444
#if defined(HAVE_HWSERIAL0)
4545
void serialEvent() __attribute__((weak));
4646
bool Serial0_available() __attribute__((weak));
47+
48+
void serialEvent() { }
49+
bool Serial0_available() { return false; }
4750
#endif
4851

4952
#if defined(HAVE_HWSERIAL1)
5053
void serialEvent1() __attribute__((weak));
5154
bool Serial1_available() __attribute__((weak));
55+
56+
void serialEvent1() { }
57+
bool Serial1_available() { return false; }
5258
#endif
5359

5460
#if defined(HAVE_HWSERIAL2)
5561
void serialEvent2() __attribute__((weak));
5662
bool Serial2_available() __attribute__((weak));
63+
64+
void serialEvent2() { }
65+
bool Serial2_available() { return false; }
5766
#endif
5867

5968
#if defined(HAVE_HWSERIAL3)
6069
void serialEvent3() __attribute__((weak));
6170
bool Serial3_available() __attribute__((weak));
71+
72+
void serialEvent3() { }
73+
bool Serial3_available() { return false; }
6274
#endif
6375

6476
void serialEventRun(void)

0 commit comments

Comments
 (0)