Skip to content

Conversation

@ypid
Copy link

@ypid ypid commented Mar 15, 2025

It worked previously because the include order is not fixed I guess and some other component always included log.h before git_ref.

In file included from src/esphome.h:10,
                 from src/main.cpp:3:
src/esphome/components/git_ref/git_ref_sensor.h: In member function 'virtual void esphome::git_ref::GitRefTextSensor::dump_con
fig()':
src/esphome/components/git_ref/git_ref_sensor.h:27:5: error: 'ESP_LOGCONFIG' was not declared in this scope
   27 |     ESP_LOGCONFIG(TAG, "GitRefTextSensor:");
      |     ^~~~~~~~~~~~~
src/esphome/components/git_ref/git_ref_sensor.h:27:5: note: the macro 'ESP_LOGCONFIG' had not yet been defined                In file included from src/esphome/components/sensor/sensor.h:3,
                 from src/esphome/components/internal_temperature/internal_temperature.h:4,
                 from src/esphome.h:11:
src/esphome/core/log.h:155: note: it was later defined here
  155 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |
$ head .esphome/build/my-sensor/src/esphome.h -n 20
#pragma once
#include "esphome/core/macros.h"
#include "esphome/components/binary_sensor/automation.h"
#include "esphome/components/binary_sensor/binary_sensor.h"
#include "esphome/components/binary_sensor/filter.h"
#include "esphome/components/button/automation.h"
#include "esphome/components/button/button.h"
#include "esphome/components/esp32/gpio.h"
#include "esphome/components/esp32/preferences.h"
#include "esphome/components/git_ref/git_ref_sensor.h"
#include "esphome/components/internal_temperature/internal_temperature.h"
#include "esphome/components/logger/logger.h"

It worked previously because the include order is not fixed I guess and
some other component always included `log.h` before git_ref.

```
In file included from src/esphome.h:10,
                 from src/main.cpp:3:
src/esphome/components/git_ref/git_ref_sensor.h: In member function 'virtual void esphome::git_ref::GitRefTextSensor::dump_con
fig()':
src/esphome/components/git_ref/git_ref_sensor.h:27:5: error: 'ESP_LOGCONFIG' was not declared in this scope
   27 |     ESP_LOGCONFIG(TAG, "GitRefTextSensor:");
      |     ^~~~~~~~~~~~~
src/esphome/components/git_ref/git_ref_sensor.h:27:5: note: the macro 'ESP_LOGCONFIG' had not yet been defined                In file included from src/esphome/components/sensor/sensor.h:3,
                 from src/esphome/components/internal_temperature/internal_temperature.h:4,
                 from src/esphome.h:11:
src/esphome/core/log.h:155: note: it was later defined here
  155 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |
```

```
$ head .esphome/build/my-sensor/src/esphome.h -n 20
    #pragma once
    #include "esphome/core/macros.h"
    #include "esphome/components/binary_sensor/automation.h"
    #include "esphome/components/binary_sensor/binary_sensor.h"
    #include "esphome/components/binary_sensor/filter.h"
    #include "esphome/components/button/automation.h"
    #include "esphome/components/button/button.h"
    #include "esphome/components/esp32/gpio.h"
    #include "esphome/components/esp32/preferences.h"
    #include "esphome/components/git_ref/git_ref_sensor.h"
    #include "esphome/components/internal_temperature/internal_temperature.h"
    #include "esphome/components/logger/logger.h"
```
@ypid ypid force-pushed the fix/missing-include-log.h branch from 200c862 to dcdbb00 Compare March 15, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant