cortext m0 PRIu8 expands to hhu and is not usable
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Package: toolchain-
Version: 1.70201.0
Toolchain: binary package provided with Platform IO in VS Code
Host Machine: Windows 10 x64
Symptom: when using PRIu8 from toolchain-
I am using Platform IO inside VS Code on Windows 10. I am compiling a library, MySensors, that uses the PRIu8 macro to format various values. I am using a Moteino M0. I have also checked compiled output for a adafruit feather m0. On these Cortex M0+ processors, the PRIu8 expands to hhu.
When I got to the definition, the the following path using Platform IO's "Got yo Definition"
C:\Users\
#define __PRI8(x) __INT8 __STRINGIFY(x)
#define PRIu8 __PRI8(u)
The macro expands using the __INT8 macro defined in toolchain-
#if (__INT8_TYPE__ == 0)
#define __INT8 "hh"
#elif (__INT8_TYPE__ == 1 || __INT8_TYPE__ == 3)
#define __INT8 "h"
#elif (__INT8_TYPE__ == 2)
#define __INT8
#elif (__INT8_TYPE__ == 4 || __INT8_TYPE__ == 6)
#define __INT8 "l"
#elif (__INT8_TYPE__ == 8 || __INT8_TYPE__ == 10)
#define __INT8 "ll"
#endif
These are common predefined macros as stated here https:/
Platform IO defines is the SAMD boards here https:/
Is there a compiler flag that Platform IO should be using? I just not sure if it is a Platform IO bug or the toolchain-
-------
Example Program:
#include <Arduino.h>
#ifdef MOTEINO_M0
#define Serial SerialUSB
#endif
void setup() {
Serial.
while (!Serial);
char buffer[512];
uint8_t value = 123;
snprintf(buffer, sizeof(buffer), "value=%" PRIu8 "\n", value);
Serial.
Serial.
Serial.
}
void loop() {
}
// end of example
-------
- platformio.ini
-------
[env:moteino_zero]
platform = atmelsam
board = moteino_zero
framework = arduino
-------
Output:
value=hu
PRIu8=hhu
-------
Expected Output:
value=123
PRIu8=hu
When adding build_flag = -E, the setup function in generated main.cpp.o file looks like this
void setup() { begin(9600) ;
SerialUSB.
while (!SerialUSB);
char buffer[512];
"hh"
"u" "\n", value);
uint8_t value = 123;
snprintf(buffer, sizeof(buffer), "value=%"
# 18 "src\\main.cpp" 3 4
# 18 "src\\main.cpp"
SerialUSB. print(buffer) ;
SerialUSB. print(" PRIu8=" );
SerialUSB.print(
# 23 "src\\main.cpp" 3 4
"hh"
# 23 "src\\main.cpp"
"u");
}