Skip to content

ESP-IDF v6: platform headers use #if CONFIG_* without #define to 0, causing -Wundef in vendored Abseil/protobuf #53

@ltowarek

Description

@ltowarek

Fix lives in: ESP-IDF (platform headers)

What the workaround does

We pass -Wno-undef to every vendored target (Abseil, protobuf, opentelemetry-cpp) via _esp_opentelemetry_apply_int_override in cmake/protobuf_setup.cmake:

# Applied to every vendored static/object/shared/module library:
-Wno-undef

Root cause

ESP-IDF v6 platform headers (assert.h, sys/time.h, pthread.h, and others) guard feature blocks with #if CONFIG_* Kconfig macros. When a Kconfig option is disabled, ESP-IDF omits the #define CONFIG_X 0 line from sdkconfig.h entirely — the symbol is simply absent. This means #if CONFIG_X expands to #if (undefined identifier), which GCC treats as #if 0 but emits a -Wundef diagnostic.

Abseil and protobuf include several ESP-IDF platform headers indirectly (through <time.h>, <pthread.h>, etc.). Under -Werror=all these -Wundef hits become hard errors, breaking the build.

This did not occur in ESP-IDF v5 because v5 always emitted #define CONFIG_X 0 for disabled Kconfig symbols in sdkconfig.h.

Proposed fix

ESP-IDF should restore the #define CONFIG_X 0 pattern for disabled Kconfig symbols, or guard its own platform headers with #ifdef CONFIG_X rather than #if CONFIG_X.

What we delete once fixed

  • The -Wno-undef entry in _esp_opentelemetry_apply_int_override in cmake/protobuf_setup.cmake

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions