A
Arduino17h ago
jim lee

How to know what target code is begin compiled for?

I'm thinking sometthing like..
c++
#ifdef PROCESSOR_A
#define PROCESSOR_A_THING
#elseif PROCESSOR_B
#define PROCESSOR_B_THING
#endif
c++
#ifdef PROCESSOR_A
#define PROCESSOR_A_THING
#elseif PROCESSOR_B
#define PROCESSOR_B_THING
#endif
Or something like that. ??
5 Replies
Maverick
Maverick16h ago
Yes, that is how I've always seen it done.
c++
#if defined(ESP8266)
extern ESP8266WebServer* webGuiServer;
#elif defined(ESP32)
extern WebServer* webGuiServer;
#endif
c++
#if defined(ESP8266)
extern ESP8266WebServer* webGuiServer;
#elif defined(ESP32)
extern WebServer* webGuiServer;
#endif
jim lee
jim leeOP16h ago
This is good! But where would I look for the different processor's tags? For example UNO, MEGA, TEENSY, ADAFRUIT XXX? I ask because mosty they use different SPI pins and I want that delt with behind the scenes in a library file. And I've never see them broken into parts like this.
c++
#if defined(xxx)
c++
#if defined(xxx)
nis
nis16h ago
@jim lee
#if defined(__SAMD21G18A__) | (__SAMD21E18A__)
#if defined(__SAMD21G18A__) | (__SAMD21E18A__)
find build extra flags in boards.txt https://github.com/adafruit/ArduinoCore-samd/blob/master/boards.txt#L113
Maverick
Maverick16h ago
Arduino Stack Exchange
List of Arduino board preprocessor #defines
When one selects a board within Arduino IDE, a preprocessor definition is added to one of the behind-the-scenes files. After a lot of hunting and some good fortune I found that the format of this
jim lee
jim leeOP11h ago
nis, thank you!! Mavrick thank you!!

Did you find this page helpful?