How to fix ESP32 ESP_LOGI(...) error: expected ')' before 'msg'
Problem:
You have code in your project such as
esp_log_fix.cpp
ESP_LOGI("MyTag", msg);where msg is a const char*, but the project fails to compile with an error message such as
example.txt
src/main.cpp:280:26: error: expected ')' before 'msg'
280 | ESP_LOGI("MyTag", msg);Solution
The format parameter can’t be any string but needs to be a string constant. Replace your code by
example.cpp
ESP_LOGI("MyTag", "%s", msg);Check out similar posts by category:
C/C++, ESP8266/ESP32
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow