Check if i compile my library in Arduino environment

Hello, I want to make a library which supports both Arduino and standard C++. when i use g++ compiler I can use this piece of code to detect OS that the library is compiled on:

#ifdef __Liunx
    //this code only get compiled in Linux
#endif

now is there any equivalent to this?

Regards.

Sorry for my bad English.

Welcome to the forum

What makes you think that the Arduino does not use standard C++ ?

well it does not use stl libraries...

Hi @Master_81. Even though it is not guaranteed by the build system, nor even documented anywhere, it is a common convention for Arduino boards platforms to define a global macro named ARDUINO.

For example, here you can see that -DARDUINO flag in the command template used by the "Arduino AVR Boards" platform to compile C++ files (which includes the .ino files of the sketch):

1 Like

Then don't use them in your code

Thank you for answering...
does ARDUINO macro work with esp32/esp8266 boards?

Try it and let us know.

It does:

It also works with all the official Arduino boards platforms (AVR, megaAVR, SAMD, SAM, Mbed OS)

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.