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

Warning about incompatible int types in mpack_snprintf calls #103

Closed
Franky1 opened this issue Jul 25, 2022 · 1 comment
Closed

Warning about incompatible int types in mpack_snprintf calls #103

Franky1 opened this issue Jul 25, 2022 · 1 comment

Comments

@Franky1
Copy link

Franky1 commented Jul 25, 2022

I copied the "amalgamation package" sources to my project and compiled it with a STM32 CubeIDE compiler.
Got some warnings about incompatible types:

format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 427 C/C++ Problem
format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 477 C/C++ Problem
format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 489 C/C++ Problem
format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 492 C/C++ Problem
format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 544 C/C++ Problem
format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 547 C/C++ Problem
format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 556 C/C++ Problem
format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=] mpack.c.line 559 C/C++ Problem

Quickfix seems to be to replace all %u with %lu in the affected mpack_snprintf calls from above, where the compiler is complaining.
Don't know if this could be fixed in the source repo here and still be platform independent?

@ludocode
Copy link
Owner

ludocode commented Jan 9, 2023

The correct fix for this is to use % PRIu32. Fixed in e55dcd5.

@ludocode ludocode closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants