fix: fixes TEST_PRINTF() expansion error #691#692
Merged
mvandervoord merged 1 commit intoThrowTheSwitch:masterfrom Aug 16, 2023
Merged
fix: fixes TEST_PRINTF() expansion error #691#692mvandervoord merged 1 commit intoThrowTheSwitch:masterfrom
mvandervoord merged 1 commit intoThrowTheSwitch:masterfrom
Conversation
fixes TEST_PRINTF() expansion error when no variadic arguments are passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes TEST_PRINTF() expansion error when no variadic arguments are passed.
I want to use TEST_PRINTF(), so I set
-D UNITY_INCLUDE_PRINT_FORMATTEDin my compilation flags.I got a compile time error:
The compiler reports an error after
__VA_ARGS__.The problem is that
TEST_PRINTF()is defined as a variadic macro, but I'm not passing any variadic argument. Sure, i may useTEST_MESSAGE()instead, but if someone wants to useTEST_PRINTF()it should work.I read this document: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
and I modified the macro
TEST_PRINTF()in the following way:So everything works: