Skip to content

Allow use of log_x() in if#5844

Merged
me-no-dev merged 1 commit into
espressif:masterfrom
FrankBoesing:fix-log
Nov 4, 2021
Merged

Allow use of log_x() in if#5844
me-no-dev merged 1 commit into
espressif:masterfrom
FrankBoesing:fix-log

Conversation

@FrankBoesing
Copy link
Copy Markdown
Contributor

if (1) log_e("error") produces a warning ("missing braces") and probably wrong code if no log level is defined.
This fixes that.

if (1) log_e("error") produces a warning ("missing braces") and probably wrong code if no log level is defined.
This fixes that.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 3, 2021

CLA assistant check
All committers have signed the CLA.

@me-no-dev me-no-dev merged commit 79e0889 into espressif:master Nov 4, 2021
@me-no-dev
Copy link
Copy Markdown
Member

Nice solution :)

@marcboon
Copy link
Copy Markdown

marcboon commented Nov 9, 2021

I've seen this solution before, but why 'do {} while(0)' instead of just '{}' ?

@FrankBoesing
Copy link
Copy Markdown
Contributor Author

Because this is a systax error:

#define foo {}

if (1) foo; 
else {}

This not:

#define foo do {} while(0)

if (1) foo; 
else {}

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.

4 participants