Commit e013b67
committed
[HardwareSerial] Fix ambiguous call of overloaded function
```
error: call of overloaded 'HardwareSerial(int, int)' is ambiguous`
1 | HardwareSerial Serialx(0, 1);
| ^
In file included from cores/arduino/WSerial.h:5,
from cores/arduino/wiring.h:47,
from cores/arduino/Arduino.h:32,
from sketch_jan27b.ino.cpp:1:
cores/arduino/HardwareSerial.h:106:5: note: candidate: 'HardwareSerial::HardwareSerial(void*, bool)'
106 | HardwareSerial(void *peripheral, bool halfDuplex = false);
| ^~~~~~~~~~~~~~
cores/arduino/HardwareSerial.h:104:5: note: candidate: 'HardwareSerial::HardwareSerial(uint32_t, uint32_t)'
104 | HardwareSerial(uint32_t _rx, uint32_t _tx);
| ^~~~~~~~~~~~~~
```
When the Rx Pin is 0 then the compiler doesn't know which constructor
to use as 0 can be interpreted like NULL. So both of them are valid:
HardwareSerial(uint32_t _rx, uint32_t _tx);
HardwareSerial(void *peripheral, bool halfDuplex = false);
Defining an explicit type avoid this issue.
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>1 parent 7193ece commit e013b67
File tree
3 files changed
+14
-3
lines changed- cores/arduino
3 files changed
+14
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
60 | 69 | | |
61 | 70 | | |
62 | 71 | | |
| |||
103 | 112 | | |
104 | 113 | | |
105 | 114 | | |
106 | | - | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
273 | 275 | | |
274 | 276 | | |
275 | 277 | | |
| |||
0 commit comments