cancel
Showing results for 
Search instead for 
Did you mean: 

Printf length modifier problem

Pawel Pielorz
Associate
Posted on May 07, 2017 at 23:19

Hello,

I have encountered problem with printf function. I am using CycloneTCP stack, where %hhu identifiers were used and workeg good. I tried to port demo applications to CubeMX etc and I got eferything working well besides printf with %hhu identifiers.

I have created new project with only this function in it, here is the part of code:

size = sprintf(buffer, '%u, %hu, %hhu\n', 123, 123, 123);

HAL_UART_Transmit_IT(&huart3, buffer, size);

What I get is:

123, 123, hu

Doing the same in original demos of stack mentioned above give good results. What I tried is to change language standard to C11 but it didn't make any change.

 Have you met such a problem?

Regards,

Pawel

#printf #stdio
1 ACCEPTED SOLUTION

Accepted Solutions
Pawel Pielorz
Associate
Posted on May 08, 2017 at 16:00

Hi, 

Thank you for your reply. As you told, it was connected with toolchain, linker, to be specific. I have found solution:

Project properties -> C/C++ Build -> Settings -> MCU GCC Linker -> Miscellaneous

Remove  '-specs=nano.specs' from Linker flags. I don't know whi I didn't notice it earlier...

Regards

View solution in original post

2 REPLIES 2
Max
ST Employee
Posted on May 08, 2017 at 11:07

Hello,

The standard libraries are coming from the compiler toolchain you are using.

If you want any relevant answer to your question, you should at least provide the compiler and the revision you are using. 

You may get better help on the compiler support channel...

Pawel Pielorz
Associate
Posted on May 08, 2017 at 16:00

Hi, 

Thank you for your reply. As you told, it was connected with toolchain, linker, to be specific. I have found solution:

Project properties -> C/C++ Build -> Settings -> MCU GCC Linker -> Miscellaneous

Remove  '-specs=nano.specs' from Linker flags. I don't know whi I didn't notice it earlier...

Regards