Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"hello_world" printf formats do not match input (IDFGH-8882) #10303

Closed
3 tasks done
gregjesl opened this issue Dec 3, 2022 · 1 comment · Fixed by #10304
Closed
3 tasks done

"hello_world" printf formats do not match input (IDFGH-8882) #10303

gregjesl opened this issue Dec 3, 2022 · 1 comment · Fixed by #10304
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@gregjesl
Copy link
Contributor

gregjesl commented Dec 3, 2022

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.1-dev-2066-g7869f4e151

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

What is the expected behavior?

"hello_world" example compiles without warnings or errors, even when the -Werror compile flag is set

What is the actual behavior?

Compile fails with two errors (see build logs)

Steps to reproduce.

Compile "hello_world" with -Werror compile flag set

Build or installation Logs.

error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [-Werror=format=]
   44 |     printf("%uMB %s flash\n", flash_size / (1024 * 1024),
      |             ~^                ~~~~~~~~~~~~~~~~~~~~~~~~~~
      |              |                           |
      |              unsigned int                long unsigned int
      |             %lu

error: format '%d' expects argument of type 'int', but argument 2 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
   47 |     printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());
      |                                     ~^           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                      |                                         |
      |                                      int                                       uint32_t {aka long unsigned int}
      |                                     %ld

More Information.

I plan on submitting a pull request to resolve the behavior

@gregjesl gregjesl added the Type: Bug bugs in IDF label Dec 3, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 3, 2022
@github-actions github-actions bot changed the title "hello_world" printf formats do not match input "hello_world" printf formats do not match input (IDFGH-8882) Dec 3, 2022
@chipweinberger
Copy link
Contributor

"Format string warnings (-Wformat) are now enabled for Xtensa and RISC-V targets. This will result in warnings whenever uint32_t values are formatted using %u or %d format specifiers. The reason is that int32_t type is defined as long which was int in a past. The same is for uint32_t. To fix the warnings, do either one of the following: 1) Use PRIx32 specifier from inttypes.h instead of d or u. 2) Cast the values being formatted to unsigned int. 3) (Not recommended) add -Wno-format compiler flag to the files where this warning occurs using set_source_files_properties CMake function."

From the v5.0 release notes.

@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally and removed Status: Opened Issue is new labels Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants