[SOLVED] How to detect code being compiled for esp32

droman
Posts: 8
Joined: Tue May 17, 2022 10:12 am

[SOLVED] How to detect code being compiled for esp32

Postby droman » Tue May 17, 2022 10:16 am

Hi. I have a shared code between the esp32 and the host system. I was seeking a way of knowing when a code is being compiled for esp32, I know I could do somethine like

Code: Select all

#if defined(__linux__) || defined(__APPLE__)
#else
#endif
but as this code may be compiled also for windows and maybe BSD I would prefer to have something like "#if defined(__esp32__)" but I didn't found any documentation regarding this. Someone has done something similar or knows if esp-idf defines something like that?

Thank you very much
Last edited by droman on Mon May 23, 2022 6:24 am, edited 1 time in total.

ESP_Sprite
Posts: 9759
Joined: Thu Nov 26, 2015 4:08 am

Re: How to detect code being compiled for esp32

Postby ESP_Sprite » Wed May 18, 2022 1:43 pm

You can use #if defined(ESP_PLATFORM).

droman
Posts: 8
Joined: Tue May 17, 2022 10:12 am

Re: How to detect code being compiled for esp32

Postby droman » Mon May 23, 2022 6:24 am

Thank you very much!

Who is online

Users browsing this forum: No registered users and 116 guests