Pls use a mangled name for the internal macro variable rc.
That's because in C/C++ this statement actually compiles:
It results in variable a being uninitialized essentially.
So with your macro, this code would have unexpected results:
Code: Select all
int rc = 7;
ESP_ERROR_CHECK(initialize_remote_control(rc));
The rc value passed to initialize_remote_control is actually random, not 7.
Also, this code would not compile because what is passed to the function is the internal esp_err_t instead of the string:
Code: Select all
esp_err_t initialize_db(const string& name)
{
//...
}
int main(int argc, const char* argv[])
{
string rc = "db1";
ESP_ERROR_CHECK(initialize_db(rc));
return 0;
}
I have a PR about this issue without any answer so far:
https://github.com/espressif/esp-idf/pull/1109
The solution is simple - just call that internal variable smth else like __internal_rc__