Skip to content

Compilation breaks when using -DUSE_ESP_IDF_LOG #4990

Closed
@salmon-charles

Description

@salmon-charles

Hello,

First, I really appreciate that someone is working on this topic: I need to redirect the logs to a telnet console and without your change it is difficult without having to refactor my code.

I am using PlatformIO with Expressif 32 [email protected].
If I look the esp32-hal-log.h file (in /.platformio/packages/framework-arduinoespressif32/cores/esp32), I can see that the USE_ESP_IDF_LOG is handled.
When I compiled my project, I have the following errors:

In file included from /Users/ces/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal.h:45:0,
                 from /Users/ces/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:35,
                 from src/main.cpp:1:
/Users/ces/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-log.h:167:13: error: expected unqualified-id before string constant
 #define TAG "ARDUINO"
             ^
lib/status/StatusManager.h:24:22: note: in expansion of macro 'TAG'
         const char * TAG = "StatusManager";
                      ^
In file included from lib/module/Module.h:3:0,
                 from src/main.cpp:2:
lib/status/StatusManager.h:24:20: error: expected ';' at end of member declaration
         const char * TAG = "StatusManager";

StatusManager.h

#pragma once

#include <Arduino.h>

#define STATUS_LED_PIN 12

class StatusManager {
    public:
        StatusManager();
        ~StatusManager();

        // States
        enum State {
            awake,
            asleep
        };

        // API
        bool setState(State state);
        State getState();

     private:
        // Constants
        const char * TAG = "StatusManager";
        
        // Members
        State state;
        
        // State handlers
        bool _handleAwakeState();
        bool _handleAsleepState();
};
}

How should I declare my class TAG ?

Moreover, I have a lot of warnings like this:

In file included from /Users/ces/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal.h:45:0,
                 from /Users/ces/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:35,
                 from /Users/ces/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiUdp.h:38,
                 from /Users/ces/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiUdp.cpp:19:
/Users/ces/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiUdp.cpp: In member function 'uint8_t WiFiUDP::begin(IPAddress, uint16_t)':
/Users/ces/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-log.h:142:84: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 #define log_e(format, ...) do {log_to_esp(TAG, ESP_LOG_ERROR, format, ##__VA_ARGS__);}while(0)

For a lot of included files that comes from external libraries (ie not related with my project code).

Thanks a lot
Charles

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions