-
Notifications
You must be signed in to change notification settings - Fork 22
Description
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
- Target: ESP32-C6
- ESP-IDF: v5.x (tested on v5.4.1)
- Library: esp-idf-cxx (latest via managed components)
- 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.