Hi
I have encountered a problem with the way the Arduino IDE expands its .ino file into a .cpp file (temp folder). It basically includes the arduino.h and tries to forward declare the methods you have in the .ino.
Here's such an expansion for an empty sketch.
#line 1 "MyProject.ino"
#include "Arduino.h"
void setup();
void loop();
#line 14
void setup() {
}
void loop() {
}
I have found two scenario's where this breaks down and causes compile errors (syntax).
-
When I have a function in my sketch that returns a type that is declared in a namespace. The extra code is inserted before the 'using namespace MyNamespace' - so the forward declaration uses a (return) type that can not be located. Also fully qualifying the type does not work for the namespace info is not copied to the forward decls.
-
Using a macro in a function declaration copies over the macro. I have some macros that declare a method. Two macro's are used a 'begin' (method name and opening bracket) and an 'end' macro (closing bracket). The 'end' macro (but not the begin macro) is also copied to the forward decls resulting in a syntax error.
So clearly some more intelligence must go into retrieving the forward decls information...
Hope it helps,
Marc
Running:
Arduino IDE 1.6.5
Windows 8.1