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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compiler warnings due to integer type mismatch #2722

Merged
merged 1 commit into from Oct 25, 2021
Merged

fix compiler warnings due to integer type mismatch #2722

merged 1 commit into from Oct 25, 2021

Conversation

mysterywolf
Copy link
Contributor

@mysterywolf mysterywolf commented Oct 23, 2021

Description of the feature or fix

This PR will silence the warning:

lv_refr.c:283:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t {aka long unsigned int}'

lv_refr.c:283:43: warning: format '%d' expects argument of type 'int', but argument 4 has type 'uint32_t {aka long unsigned int}'

This is an awkward situation: some compilers think that uint32_t is long unsigned int (which means %lu should be used), and some of those think that uint32_t is unsigned int (which means %u should be used).

Thus, I think the best solution is to use unsigned int to replace uint32_t, and use %u to replace %d. Every compiler is happy.馃槀

Checkpoints

@embeddedt embeddedt changed the title fix(warning|lv_refr.c): '%d' expects argument of type 'int', but argument has type 'uint32_t {aka long unsigned int} fix(refr) silence compiler warning due to integer type mismatch Oct 23, 2021
@kisvegabor
Copy link
Member

kisvegabor commented Oct 25, 2021

I like this solution, thank you!

Could you apply it to the other files too that are mentioned in #2705?

@xiaoxiang781216
Copy link
Collaborator

I like this solution, thank you!

Could you apply it to the other files too that are mentioned in #2705?

we can catch more similar warnings if we enable CI for arm/xtensa target.

@kisvegabor
Copy link
Member

we can catch more similar warnings if we enable CI for arm/xtensa target

It'd be great to have ARM/Xtensa CI tests too. Contribution would be welcome on it 馃檪

@mysterywolf
Copy link
Contributor Author

mysterywolf commented Oct 25, 2021

I like this solution, thank you!

Could you apply it to the other files too that are mentioned in #2705?

For sure, no problem.
All set. Please double check.馃榾

@embeddedt embeddedt changed the title fix(refr) silence compiler warning due to integer type mismatch fix compiler warnings due to integer type mismatch Oct 25, 2021
@kisvegabor kisvegabor merged commit 97bf749 into lvgl:master Oct 25, 2021
@kisvegabor
Copy link
Member

Thank you!

@FASTSHIFT
Copy link
Collaborator

@mysterywolf
I think %"PRIu32" should be used for printing of uint32_t type (see inttypes.h for details).
We should use the standard type provided by stdint.h.

@mysterywolf
Copy link
Contributor Author

mysterywolf commented Dec 20, 2021

I think this PR's method is better than both of ours: lvgl/lv_demos#146 . How do you think? By the way, could you please help me to review this PR: #2919 @FASTSHIFT

@FASTSHIFT
Copy link
Collaborator

I think this PR's method is better than both of ours: lvgl/lv_demos#146 . How do you think? By the way, could you please help me to review this PR: #2919 @FASTSHIFT

I agree with you.

kisvegabor pushed a commit that referenced this pull request Dec 20, 2021
* fix:Removed string format warnings for int32_t and uint32_t
re-handle #2722

* feat(rt-thread): add the option of built-in examples
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

Successfully merging this pull request may close these issues.

None yet

5 participants