conditional processing interacts oddly with includes and variable definitions #2630
Labels
Component: Preprocessor
The Arduino sketch preprocessor converts .ino files into C++ code before compilation
Milestone
TL;DR simplification of a more complicated real example - It appears as if the IDE compile-time code that processes the sketch to handle automatic function declarations injects the results blindly after the last #include, even if there are conditional compilation directives in use:
becomes (in /var/folders/nw/..../sketch.cpp)
and results in (as expected...) compile failures because any of the functions defined after loop() have no associated declarations in scope:
Obviously, pre-declaring the functions explicitly, or ordering the definitions and uses in such a way as to avoid the need for explicit forward declarations is the "proper" way to solve the problem - but that begs the question of the value of automagically computing declarations... In the spirit of making the automagic work, I moved the conditional variable declaration AFTER some other variable declaration/definition, which seems to patch things back up...
Yeah, I know the IDE handles conditionals poorly, but this type of silent failure is effectively impossible for the most users to debug...
The text was updated successfully, but these errors were encountered: