Page 1 of 1

[SOLVED] How to detect code being compiled for esp32

Posted: Tue May 17, 2022 10:16 am
by droman
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

Re: How to detect code being compiled for esp32

Posted: Wed May 18, 2022 1:43 pm
by ESP_Sprite
You can use #if defined(ESP_PLATFORM).

Re: How to detect code being compiled for esp32

Posted: Mon May 23, 2022 6:24 am
by droman
Thank you very much!