Description
Describe the request
I am unable to find a pre-processor defined symbol to unambiguously detect that the compilation is Arduino.
Every other compiler infrastructure I have used has one of these. They are important for producing portable code.
It is trivial to add, can one please be added?
(Why doesn't Arduino have one already?)
Describe the current behavior
There is no symbol, such as ARDUINO, ARDUINO_IDE or ARDUINO_CLI defined during compilation.
Arduino IDE version
2.33
Operating system
Windows
Operating system version
windows 11 pro
Additional context
This is not a new problem. This question in a number of forms can be found in the arduino forum.
A "recent" thread started by user:"stecoop" is a delightful example of a professional programmer with a simple need, asking a reasonable question, and getting a lot of useless non-answers from folks who don't understand the plainly stated question. A whole lot of useless pain.
https://forum.arduino.cc/t/predefined-preprocessor-variables/1002170/11
One supposes this developer community has experienced compiler detection before. Here are some examples gathered from my portable projects, just to demonstrate how widespread (and old) this practice is:
#ifdef BORLANDC
#ifdef _MSC_VER
#ifdef IBMC
#ifdef GNUC
#ifdef ESP_PLATFORM
One can see a somewhat "standard" industry pattern exists:
<your "name">
Following that, the new symbol could be ARDUINO.
I'm happy to join the fray and figure out where the "-D ARDUINO" goes, and make the change...
Issue checklist
- I searched for previous requests in the issue tracker
- I verified the feature was still missing when using the latest nightly build
- My request contains all necessary details