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

Add do while (0) to Id and ID macros #437

Merged
merged 1 commit into from
Oct 3, 2023
Merged

Add do while (0) to Id and ID macros #437

merged 1 commit into from
Oct 3, 2023

Conversation

hugobpontes
Copy link
Contributor

The ID and Id macros were giving me syntax warnings saying a ";" was missing anytime I used them, which was very annoying as in my IDE (STM32Cube) it filled the code (even other lines) with underlining, making it a bit unreadable.
To fix it I added do {} while (0) to those to macros, and the error disappeared.
I suppose it's possible that other people, especially in other IDEs were not getting this warning but I think my proposed changes only improve the code for people with the same problem as me and will not affecting others.

If you wish to make any change or want me to make any change before merging, feel free to!

@th-sabik th-sabik merged commit 432a31f into rokath:master Oct 3, 2023
1 check failed
@rokath
Copy link
Owner

rokath commented Oct 3, 2023

Thanks for the pull request, Hugo! I recommend to use the macros trice, Trice and TRice instead of using TRICE( id(n), TRICE( Id(n) and TRICE (ID(n). The TRICE macros are inlining code each time you use them causing bigger firmware images when you use them many times. The trice, Trice and TRice macros are function calls.

@hugobpontes
Copy link
Contributor Author

hugobpontes commented Oct 3, 2023

I wanted a 32 bit timestamp and used trice, so trice(iD(n)) was generated, but I got no timestamp. When I quickly looked in trice.h I assumed only ID would give me a 32-bit timestamp, so when I used TRICE and TRICE(ID(n)) was generated and worked, I assumed TRICE and ID was the way to go.
After seeing your comment, I tested with TRice(iD(n)) and it works as well (of course :) ), so thank you for the tip!

@hugobpontes hugobpontes deleted the fix_ID_Id_compiler_warnings branch October 3, 2023 11:54
@rokath
Copy link
Owner

rokath commented Oct 3, 2023

https://github.com/rokath/trice/blob/master/docs/TriceUserGuide.md#14-trice-timestamps

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.

3 participants