2025-03-26 9:22 AM
The compiler is correctly warning about an int to char conversion for the following code from syscalls.c:
extern int __io_getchar(void) __attribute__((weak));
...
__attribute__((weak)) int _read(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
*ptr++ = __io_getchar(); // Warning here
}
return len;
}
Whilst the behaviour here is as intended (assuming EOF is not expected), the warning is a pain for any projects using -Wconversion.
Could this please be fixed by adding a cast?
*ptr++ = ( char )__io_getchar();
This is for an STM32G484CEUx device, if that's important.
2025-03-26 2:41 PM
You can make that change yourself. The syscalls.c does not get re-generated every time you run CubeMX "generate code", so it won't overwrite your changes.
Though, yes, it would be nice if syscalls.c had lots simple mods to pass more strict compiler checks, like adding UNUSED() for the function parameters that are not used in the stub functions.
2025-03-27 2:04 AM
Thanks, that will save me some "pain" - I hadn't spotted that those files aren't regenerated.