Page 1 of 1

ESP_LOGI and ESP_ERROR_CHECK issues in C++

Posted: Sun Nov 26, 2023 3:06 pm
by greycon
Hi, I've been chasking this for a while. It's not an issue that affects generated code, but rather produces lots of annoying "errors" in the IDE. I've narrowed it down to a trivial main.cpp program:

This program (Without the extern "C") does not show any IDE errors when written as main.c

Code: Select all

#include "esp_log.h"
#include "esp_err.h"
#include "esp_err.h"
#include "nvs_flash.h"


extern "C" {

void app_main(void) {
	ESP_LOGI("XXX", "YYY");
    ESP_ERROR_CHECK(nvs_flash_init());

}
}

The ESP_LOGI macro shows a simple "Syntax Error" in the IDE.
The ESP_ERROR_CHECK shows an "Invalid Argumements" error, or sometimes in a bigger program an error that "__ASSERT not found"

I don't mind re-codeing the logging macro to:

Code: Select all

esp_log_write(ESP_LOG_INF", "Blah","Blah");
But I can't find a way around the ERROR check macro, and it's used a lot in sample code, and I would like to keep this. Anyone know a workaround?

Re: ESP_LOGI and ESP_ERROR_CHECK issues in C++

Posted: Mon Nov 27, 2023 2:24 am
by ESP_kondalkolipaka
Hello,

To verify further, could you please share more details on what IDE are you referring to - Eclipse or VSCode?

Please share an IDE version and a sample project to test this scenario.

Thanks

Re: ESP_LOGI and ESP_ERROR_CHECK issues in C++

Posted: Mon Nov 27, 2023 4:58 am
by ESP_kondalkolipaka
I could reproduce this problem with Eclipse IDE.

I see this "syntax error" marker on ESP_LOGI() in Eclipse (with only .cpp files). I think this is something to do with "extern" syntax and how Indexer is building https://bugs.eclipse.org/bugs/show_bug.cgi?id=258292

Let me see if I can find something on this.

Re: ESP_LOGI and ESP_ERROR_CHECK issues in C++

Posted: Sat Dec 02, 2023 3:43 pm
by greycon
Sorry, I should have been clear - I am usign the Eclipse IDF plugin. And if you do happen to find some workaround for the indexer issue, that would be great, thanks for your time.