-
-
Notifications
You must be signed in to change notification settings - Fork 114
#include "arduino.h" being added in inconsistent places #248
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
Comments
Which version of the Arduino IDE are you using on each computer? |
@ianahner wrote: 1.8.4 on both computers. Linux on one machine, Windows 10 on the other. The Windows 10 machine was ultimately the one that had the issue, though both seem to be fairly arbitrary in their placement. |
Please provide a minimal complete sketch that we can use to reproduce the issue. |
I will try to build a sketch and tweak it until I can reliably land the #include inside a #ifdef... The computer that was doing it is at work, so no joy until I'm back there. Perhaps though we could look at something as simple as always adding that at the first line? Without me digging around for days, does anyone know which bit of code handles that insertion? I will try to get a reproducible chunk of code when I'm back at work. |
What's weird is that IIRC builder preprocesses the file first, and then decides based on the result where to insert the Arduino.h include and function prototypes (using the preprocessor annotations to backreference to the original line numbers). Though perhaps this applies only to function prototypes and not Arduino.h perhaps... |
Closing as probably resolved. It will not be possible to verify due to not having sufficient information to reproduce the original issue. If anyone is still having this type of issue with the latest version of arduino-builder/Arduino IDE and can provide a minimal reproducible example, please comment here and we'll investigate. |
Imported from arduino/Arduino#6721
@ianahner wrote:
I do not have time to chase this issue at the moment, but if I find time I will try to track down the cause and append more info. The issue is this:
Different computers have proven to be inconsistent in where they put the #include arduino.h line.
It is always before setup loop, which is good, but in an example today there was an issue.
I was supporting two different hardware designs, one using software serial and one using hardware serial. There was therefore the following code above the setup loop:
sudo code:
The arduino IDE chose to add the include in the middle so that the following occurred:
Due to the fact that the design 1 bit didn't currently apply, the compiler missed the include and spit out a bunch of errors. The problem was resolved by manually including arduino.h, but looking in the tmp file that was generated, I can see that it was still ALSO included inside the #ifdef. This code should be reviewed to avoid this.
I will work on it if I have time, but meanwhile if anyone more familiar with the way the arduino ide build system functions, perhaps you could guess at why this is happening. I do not think it is unreasonable for #ifdef to exist in the header of a file. I know that is not typical of arduino, but in the embedded world where I typically work that is fairly standard practice.
The text was updated successfully, but these errors were encountered: