-->
Page 1 of 1

Where is "__AVR__" defined or what is the ESP equivalent?

PostPosted: Fri Apr 24, 2015 7:44 am
by Ribeiro Santos
Hi,

I'm learning to create libraries to ESP8266 to use in Arduino IDE.

Lot of code has, by example:
#if defined(__AVR__)
#include <TFT_Arduino_Mega.h>
#else
#include <TFT_Arduino.h>
#endif

where is "__AVR__" defined and/or where is the equivalent to the ESP board?

Thanks a lot,
Ribeiro

Re: Where is "__AVR__" defined or what is the ESP equivalent

PostPosted: Fri Apr 24, 2015 8:36 am
by Chris--A
It doesn't matter where its defined (__AVR__), its only meant for AVR processors.

As for the ESP. The IDE version 1.6.1 outputs the following definitions:

ARDUINO_ESP8266_ESP01
ARDUINO_ARCH_ESP8266

Using the second one is probably better (seems less likely to change).
These aren't added by the Espressif core, but in the the IDE using -D compiler options.

Re: Where is "__AVR__" defined or what is the ESP equivalent

PostPosted: Fri Apr 24, 2015 1:13 pm
by Zeron
#if defined(ESP8266) also works see: https://github.com/esp8266/Arduino/comm ... c0b8c5ce61

Re: Where is "__AVR__" defined or what is the ESP equivalent

PostPosted: Fri Apr 24, 2015 8:36 pm
by Chris--A
Zeron wrote:#if defined(ESP8266) also works see: https://github.com/esp8266/Arduino/comm ... c0b8c5ce61


This wasn't added in 1.6.1, I cannot use it. I'm downloading 1.6.1-p1 (windows) to see if its there.