conditional compilation macro

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

conditional compilation macro

Postby snahmad75 » Thu Mar 15, 2018 12:52 pm

Hi,

I need to use conditional compilation macro for ESP32. My C++ classes are used on Windows, Kiel and other platform.
Any useful macro I can use. Do I need to define my own macro.


Thanks,
Naeem

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: conditional compilation macro

Postby snahmad75 » Thu Mar 15, 2018 3:59 pm

I am adding macro for conditional compilation.

CXXFLAGS += -ESP32

xtensa-esp32-elf-c++.exe: error: unrecognized command line option '-ESP32'

I am getting error.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: conditional compilation macro

Postby kolban » Thu Mar 15, 2018 4:21 pm

Do define a macro value you supply:

Code: Select all

-D<Name>
or

Code: Select all

-D<Name>=<Value>
You can then use:

Code: Select all

#ifdef NAME
....
#endif
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: conditional compilation macro

Postby snahmad75 » Thu Mar 15, 2018 5:17 pm

Thanks.
It is working.

CXXFLAGS+= -std=c++11 -DESP32

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

Re: conditional compilation macro

Postby ESP_Sprite » Fri Mar 16, 2018 1:43 am

FYI, ESP-IDF itself always defines ESP_PLATFORM , so you can use that as well.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: conditional compilation macro

Postby snahmad75 » Fri Mar 16, 2018 8:58 am

Thanks.

Who is online

Users browsing this forum: No registered users and 120 guests