2024-04-29 08:14 PM
Hi guys,
I'm executing the "printf" in CubeIDE to output uint64_t with "%llu", but the printout is wrong.
Why does it not support "%llu"?
However it can work well in Keil.
//debug.c
int __io_putchar(int ch) //Redirect printf to uart
{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
return (ch);
}
//main.c
int main()
{
//***
printf("%llu\r\n", (uint64_t)1 ); //Hope to output "1", but output "lu"
}
Solved! Go to Solution.
2024-04-29 11:29 PM
Hi,
Thanks for answering, I found that CubeIDE uses the "reduced C", and the problem can be solved by modifying to "standard C" .
2024-04-29 10:48 PM - edited 2024-04-29 10:49 PM
This is because the C runtime library in the GNU toolchain supplied with CubeIDE has limited implementation of printf. It does not support %ll and some other formats. Keil MDK provides their own runtime library, high quality and thread aware. This is one of reasons why Keil MDK is worth its price ))
2024-04-29 11:13 PM
Hi,
just a simple test : what its doing with : "%lu" ?
printf("%lu\r\n", (uint64_t)1 );
2024-04-29 11:25 PM
I used a ftp server lib which actually used "%llu",this makes my project cannot work. because it returns wrong message from ftp server.
2024-04-29 11:29 PM