Page 1 of 1

Common source code (ESP-IDF vs Linux)

Posted: Fri Jun 01, 2018 10:19 am
by PaulVdBergh
Hello,

In my project I write C++ classes which are 99% identical (at source level) for both linux (RPi) and ESP-IDF. Only minor differences exists, for example ESP_LOGx(...) vs syslog(...).

I'm looking for compile time defines identifying the different compilers, so that this pseudo-code works:

Code: Select all

#ifdef RPi
	#define LOG(...) syslog(...)
#elif defined ESP_IDF
	#define LOG(...) ESP_LOGI(...)
#else
	#error "Incompatible code..."
#endif
Thanks in advance,

Paul.

Re: Common source code (ESP-IDF vs Linux)

Posted: Sat Jun 02, 2018 8:00 am
by ESP_Sprite
ESP-IDF always defines ESP_PLATFORM, so you can use that to see if you're compiling for an Espressif part.