itoa() and utoa() have bad results; definitions of data types
Hello,
I have bad experience with using itoa() or utoa() functions in the SW4STM32. I am not sure if the problem is in the GCC or AC6 or other part of the System Workbench. I am programming STM32F4.
For example if I use
static char buf[12] = {0};
uint32_t n1 = 900;
itoa(n1, (char*) buf, 11);
in some user defined function. Then itoa() or utoa() gives me result {‘7’, ‘4’, ‘9’, 0, 0, 0, 0, 0 ,0, 0, 0, 0} in the buf, it means “749”. It doesn’t matter if n1 is int or static int.
Eclipse CDT (which contain GCC cross compiler support, C/C++ development tools, GDB, etc.) - all in version 9.2.1.2017...
AC6 C/C++ Debugging Tools for MCU - version 2.3.1.2018...
AC6 C/C++ Embedded Development Tools for MCU - version 2.7.2.2018...
AC6 Linker Script Editor - version 1.11.1.2017...
etc.
I see the only workaround - it is to use sprintf();
However I’d like to know the cause and solution of the problem of the itoa() or utoa().
Additional question:
Where I can find proper documentation for my compiler? Is my GCC version 9.2.1 or is it only Eclipse version? I was searching through IDE files (stdlib.h, etc.) but I have found only
char * itoa (int, char *, int);
char * utoa (unsigned, char *, int);
prototypes without any description. I would like to know also the size and signedness of default datatypes (char, int, ...). I cannot find it in the h-files.
typedef __INT8_TYPE__ __int8_t;
and similar for uint8_t,... int64_t. There is not explicitly specified the connection with unsigned/signed short/long int anywhere in the h-files.