ESP_ERROR_CHECK macro syntax
Posted: Fri May 19, 2017 10:00 am
Do we have a syntax style document for the IDF? The following may seem like a nitpick but...
Looking at the definition of the ESP_ERROR_CHECK macro in components/esp32/include/esp_err.h, I notice that it includes a final semicolon. Traditionally this is not done, so as to not break statements like this:
The current syntax (in master) leads to
which is a syntax error (note the two semicolons)
One can get around this with:
But most people put a final semicolon regardless of the need, following a standard function call syntax. In the current tree I see a final semicolon is present in each case (where it is redundant with the current macro).
Fixing this will break programs that do not have a final semicolon in the invocation.
cheers
Looking at the definition of the ESP_ERROR_CHECK macro in components/esp32/include/esp_err.h, I notice that it includes a final semicolon. Traditionally this is not done, so as to not break statements like this:
Code: Select all
if (some_condition)
ESP_ERROR_CHECK (some_func());
else
ESP_ERROR_CHECK (some_other_func());
Code: Select all
if (some_condition)
do {
esp_err_t rc = (some_func());
...
} while(0);;
else
do {
esp_err_t rc = (some_other_func());
...
} while(0);;
Code: Select all
error: 'else' without a previous 'if'
Code: Select all
if (some_condition)
ESP_ERROR_CHECK (some_func())
else
ESP_ERROR_CHECK (some_other_func())
Fixing this will break programs that do not have a final semicolon in the invocation.
cheers