cancel
Showing results for 
Search instead for 
Did you mean: 

printf %llu with error

PeterMu
Associate II

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"
}

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

Thanks for answering, I found that CubeIDE uses the "reduced C", and the problem can be solved by modifying to "standard C" .

View solution in original post

4 REPLIES 4
Pavel A.
Evangelist III

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 ))

 

AScha.3
Chief III

Hi,

just a simple test : what its doing with :  "%lu" ?

printf("%lu\r\n", (uint64_t)1 ); 

 

If you feel a post has answered your question, please click "Accept as Solution".

I used a ftp server lib which actually used "%llu",this makes my project cannot work. because it returns wrong message from ftp server.

Hi,

Thanks for answering, I found that CubeIDE uses the "reduced C", and the problem can be solved by modifying to "standard C" .