Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Build fails on ESP32-C6 due to missing I2C_NUM_1 in i2c_cxx.cpp #38

@mistersomov

Description

@mistersomov

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

The code should compile on all ESP32 variants, including those that only support a single I2C controller, such as ESP32-C6.

Actual behavior (suspected bug)

When building a project that includes esp-idf-cxx on ESP32-C6, the build fails with the following error:

managed_components/espressif__esp-idf-cxx/i2c_cxx.cpp:22:15: error: 'I2C_NUM_1' was not declared in this scope; did you mean 'I2C_NUM_0'? 22 | static_assert(I2C_NUM_1 == 1, "I2C_NUM_1 must be equal to 1");

The following line in i2c_cxx.cpp:

static_assert(I2C_NUM_1 == 1, "I2C_NUM_1 must be equal to 1");
#endif

fails on ESP32-C6 because the macro SOC_I2C_NUM is not defined at all for this target, which causes the preprocessor to evaluate an undefined identifier in a #if, leading to a compile-time error.

Error logs or terminal output

/managed_components/espressif__esp-idf-cxx/i2c_cxx.cpp:22:15: error: 'I2C_NUM_1' was not declared in this scope; did you mean 'I2C_NUM_0'?
   22 | static_assert(I2C_NUM_1 == 1, "I2C_NUM_1 must be equal to 1");
      |               ^~~~~~~~~
      |               I2C_NUM_0
ninja: build stopped: subcommand failed.

Steps to reproduce the behavior

  1. Target: ESP32-C6
  2. ESP-IDF: v5.x (tested on v5.4.1)
  3. Library: esp-idf-cxx (latest via managed components)
  4. Host: Windows 11

Project release version

v5.4.1

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Windows

Operating system version

Windows 11

Shell

PowerShell

Additional context

The build works fine on ESP32 (original) where both SOC_I2C_NUM and I2C_NUM_1 are defined. The issue only appears on targets with a single I2C controller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions