Common source code (ESP-IDF vs Linux)

User avatar
PaulVdBergh
Posts: 58
Joined: Fri Feb 23, 2018 4:45 pm
Location: Brasschaat, Belgium

Common source code (ESP-IDF vs Linux)

Postby PaulVdBergh » Fri Jun 01, 2018 10:19 am

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.

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

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

Postby ESP_Sprite » Sat Jun 02, 2018 8:00 am

ESP-IDF always defines ESP_PLATFORM, so you can use that to see if you're compiling for an Espressif part.

Who is online

Users browsing this forum: Baidu [Spider] and 141 guests