Why can't I do this:
SimObjectsDev.ino:
SimServoDev.h:
I'm writing a wrapper for the Servo library to make it very easy to connect servo-driven gauges to X-Plane. You can see the code here.
My SimServo class is defined in the SimServoDev.h header file. SimServo contains a plain Servo as a member. I want to #include <Servo.h> within SimServoDev.h, but Arduino IDE is having none of it. When I do this, it complains that Servo does not define a type. Replace the angle-brackets with quote marks, it doesn't find the file.
The workaround is to #include <Servo.h> within the main sketch, just before #include "SimServoDev.h". Then everything works perfectly.
I understand the Arduino IDE is notorious for doing a preposterous amount of preprocessing, which I think is the culprit. (I discovered the typedef-as-function-argument trap earlier today too.) Can it be circumvented re header files? I can't abandon the Arduino IDE without finding another method of compiling code as easy-to-use for non-programmers. The purpose of the SimObject classes is to open up Teensy-based hardware to X-Plane users who aren't willing to learn much C++ (which is most of them).
The entire project is on GitHub, which thinks it's in JavaScript because I uploaded Doxygen-generated autodocs alongside the source code.
SimObjectsDev.ino:
Code:
#include "SimServoDev.h"
SimServo myServo (blah blah blah);
setup() ...
loop()...
SimServoDev.h:
Code:
#include <Servo.h> // behold the vanishing #include statement!
class SimServo {
...
private:
Servo _servo;
};
I'm writing a wrapper for the Servo library to make it very easy to connect servo-driven gauges to X-Plane. You can see the code here.
My SimServo class is defined in the SimServoDev.h header file. SimServo contains a plain Servo as a member. I want to #include <Servo.h> within SimServoDev.h, but Arduino IDE is having none of it. When I do this, it complains that Servo does not define a type. Replace the angle-brackets with quote marks, it doesn't find the file.
The workaround is to #include <Servo.h> within the main sketch, just before #include "SimServoDev.h". Then everything works perfectly.
I understand the Arduino IDE is notorious for doing a preposterous amount of preprocessing, which I think is the culprit. (I discovered the typedef-as-function-argument trap earlier today too.) Can it be circumvented re header files? I can't abandon the Arduino IDE without finding another method of compiling code as easy-to-use for non-programmers. The purpose of the SimObject classes is to open up Teensy-based hardware to X-Plane users who aren't willing to learn much C++ (which is most of them).
The entire project is on GitHub, which thinks it's in JavaScript because I uploaded Doxygen-generated autodocs alongside the source code.