Is there any defined macro that I can use to detect the ESP32-xx architecture at build time? I've got some code that I would like to be able to compile for different architectures like ARM or x86. For example, I can check for the existence of the "__ARM_ARCH" macro to see if it is being built for ARM. Is there some similar macro for ESP32-xx?
Thanks!
Macro to detect ESP32-xx architecture
-
- Posts: 1709
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Macro to detect ESP32-xx architecture
As to the architecture, you can use
Then there is ESP_PLATFORM which "can be used to detect that build happens within ESP-IDF".
For the specific target SoC, sdkconfig.h defines the current target, i.e.
Code: Select all
#ifdef __XTENSA__
...
#endif
#ifdef __riscv
...
#endif
For the specific target SoC, sdkconfig.h defines the current target, i.e.
Code: Select all
#if CONFIG_IDF_TARGET_ESP32
...
#elif CONFIG_IDF_TARGET_ESP32S2
...
#elif CONFIG_IDF_TARGET_ESP32C3
...
#elif CONFIG_IDF_TARGET_ESP32S3
...
#elif CONFIG_IDF_TARGET_ESP32H4
...
#elif CONFIG_IDF_TARGET_ESP32C2
...
#elif CONFIG_IDF_TARGET_ESP32C6
...
#elif CONFIG_IDF_TARGET_ESP32H2
...
#endif
Who is online
Users browsing this forum: Majestic-12 [Bot] and 104 guests