Preprocessor symbol for ESP32 code?

fesp32@joov.de
Posts: 13
Joined: Tue May 02, 2017 9:33 am

Preprocessor symbol for ESP32 code?

Postby fesp32@joov.de » Tue May 02, 2017 9:49 am

Problem: I have code which runs on many platforms, e.g. Linux and some uControllers. I need a preprocessor symbol can I use to detect that I am compiling for ESP32 under the esp-idf. (This must not come from a ESP32 header file because I need the symbol to detect whether the ESP32 headers are available at all.)

I looked at the output of "xtensa-esp32-elf-gcc -dM -E - < /dev/null" and I figured out I can use:
#ifdef __XTENSA__
...
#endif

This works for me.

The remaining question is: Is there a standard convention when compiling for ESP32?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Preprocessor symbol for ESP32 code?

Postby ESP_igrr » Tue May 02, 2017 1:22 pm

http://esp-idf.readthedocs.io/en/latest ... efinitions

We use ESP_PLATFORM when we need to detect that compilation happens in IDF environment.

fesp32@joov.de
Posts: 13
Joined: Tue May 02, 2017 9:33 am

Re: Preprocessor symbol for ESP32 code?

Postby fesp32@joov.de » Wed May 03, 2017 9:08 am

Many thanks, this works. I was not aware of this good documentation source on ESP32! I like that. There is no (obvious) link to it from the espressif.com site!

Who is online

Users browsing this forum: No registered users and 84 guests