ESP_LOGI and ESP_ERROR_CHECK issues in C++

greycon
Posts: 14
Joined: Fri Nov 03, 2023 9:59 pm

ESP_LOGI and ESP_ERROR_CHECK issues in C++

Postby greycon » Sun Nov 26, 2023 3:06 pm

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?

ESP_kondalkolipaka
Posts: 161
Joined: Wed Jul 17, 2019 5:26 pm

Re: ESP_LOGI and ESP_ERROR_CHECK issues in C++

Postby ESP_kondalkolipaka » Mon Nov 27, 2023 2:24 am

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

ESP_kondalkolipaka
Posts: 161
Joined: Wed Jul 17, 2019 5:26 pm

Re: ESP_LOGI and ESP_ERROR_CHECK issues in C++

Postby ESP_kondalkolipaka » Mon Nov 27, 2023 4:58 am

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.

greycon
Posts: 14
Joined: Fri Nov 03, 2023 9:59 pm

Re: ESP_LOGI and ESP_ERROR_CHECK issues in C++

Postby greycon » Sat Dec 02, 2023 3:43 pm

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.

Who is online

Users browsing this forum: No registered users and 59 guests