Page 1 of 1

conditional compilation macro

Posted: Thu Mar 15, 2018 12:52 pm
by snahmad75
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

Re: conditional compilation macro

Posted: Thu Mar 15, 2018 3:59 pm
by snahmad75
I am adding macro for conditional compilation.

CXXFLAGS += -ESP32

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

I am getting error.

Re: conditional compilation macro

Posted: Thu Mar 15, 2018 4:21 pm
by kolban
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

Re: conditional compilation macro

Posted: Thu Mar 15, 2018 5:17 pm
by snahmad75
Thanks.
It is working.

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

Re: conditional compilation macro

Posted: Fri Mar 16, 2018 1:43 am
by ESP_Sprite
FYI, ESP-IDF itself always defines ESP_PLATFORM , so you can use that as well.

Re: conditional compilation macro

Posted: Fri Mar 16, 2018 8:58 am
by snahmad75
Thanks.