Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor define to identify compiling with Arduino-IDE/CLI #2751

Closed
3 tasks done
pdppdp opened this issue Nov 10, 2024 · 2 comments
Closed
3 tasks done

Preprocessor define to identify compiling with Arduino-IDE/CLI #2751

pdppdp opened this issue Nov 10, 2024 · 2 comments
Assignees
Labels
conclusion: invalid Issue/PR not valid topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@pdppdp
Copy link

pdppdp commented Nov 10, 2024

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
@pdppdp pdppdp added the type: enhancement Proposed improvement label Nov 10, 2024
@per1234 per1234 transferred this issue from arduino/arduino-ide Nov 10, 2024
@per1234 per1234 self-assigned this Nov 10, 2024
@per1234 per1234 added topic: code Related to content of the project itself topic: build-process Related to the sketch build process labels Nov 10, 2024
@per1234
Copy link
Contributor

per1234 commented Nov 10, 2024

Hi @pdppdp.

the new symbol could be ARDUINO.

This is already a common convention, defined by all official Arduino boards platforms:

And also by all 3rd party platforms I am aware of, for example;

So if you find a 3rd party platform that does not define this macro, please submit a bug report to the platform developers.

As for your proposal that the Arduino development tools should define the macro, we avoid any such thing because we want to give the platform developers maximum control (for example, some compilers use a different mechanism than a -D flag to define global macros).

It would be very beneficial for Arduino to provide formal documentation for the interfaces such as the ARDUINO macro that a platform is expected to provide, and we are tracking that task at #985.

@per1234 per1234 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2024
@per1234 per1234 added the conclusion: invalid Issue/PR not valid label Nov 10, 2024
@pdppdp
Copy link
Author

pdppdp commented Nov 11, 2024

Appreciate your effort.

The statement "we are tracking" might be technically correct,. That issue started in 2015, garnered 5 comments in a year, and has lain dormant since. Hard to be encouraged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: invalid Issue/PR not valid topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants