Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix format specifier for printing CAN message ID in CanMsg.h.#198

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aentinger merged 1 commit intoarduino:masterfromhaydenroche5:mbed_can_msg_fix
Sep 4, 2023

Conversation

haydenroche5
Copy link
Contributor

Reproducible with an empty sketch:

// my_example.inovoid setup(){}void loop(){}

Compiled with:

arduino-cli compile --build-property compiler.cpp.extra_flags='-Wno-unused-parameter -Werror' --fqbn arduino:mbed_nano:nano33ble --log-level trace --verbose --warnings all my_example/my_example.ino

Tail of the output:

In file included from /home/hroche/.arduino15/packages/arduino/hardware/mbed_nano/4.0.4/cores/arduino/api/CanMsgRingbuffer.h:17:0,                 from /home/hroche/.arduino15/packages/arduino/hardware/mbed_nano/4.0.4/cores/arduino/api/CanMsgRingbuffer.cpp:12:/home/hroche/.arduino15/packages/arduino/hardware/mbed_nano/4.0.4/cores/arduino/api/CanMsg.h: In member function 'virtual size_t arduino::CanMsg::printTo(arduino::Print&) const':/home/hroche/.arduino15/packages/arduino/hardware/mbed_nano/4.0.4/cores/arduino/api/CanMsg.h:71:71: error: format '%X' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t {aka long unsigned int}' [-Werror=format=]     len = snprintf(buf, sizeof(buf), "[%08X] (%d) : ", id, data_length);                                                        ~~             ^cc1plus: all warnings being treated as errorsUsed platform     Version Path                                                             arduino:mbed_nano 4.0.4   /home/hroche/.arduino15/packages/arduino/hardware/mbed_nano/4.0.4Error during build: exit status

Regarding the X format specifier: C standard §7.21.6.1: "The unsigned intargument is converted to ..." On some platforms (e.g. mbed_nano), uint32_t,which is what's being printed here, is an unsigned long int, so this code causesa compiler warning. The fix is to use the format specifiers from §7.8.1,specifically PRIX32.
Copy link
Contributor

@aentingeraentinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM 👍 That's a good one, thanks for fixing it@haydenroche5 🚀 .

haydenroche5 reacted with thumbs up emoji
@aentingeraentinger merged commit68d3e0d intoarduino:masterSep 4, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@aentingeraentingeraentinger approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@haydenroche5@aentinger@per1234

[8]ページ先頭

©2009-2025 Movatter.jp