Creating a library of C++ classes for Arduino; How to #include "Arduino.h", "WProgram.h"? I've written 6 C++ classes on the CLion IDE to be used on Arduino. One of these classes uses a C++ library called "Adafruit_PWMServoDriver.cpp" provided by Adafruit to use the PWM driver they sell. I'm trying to test my code in a main.cpp, but upon building my code, I noticed that "Adafruit_PWMServoDriver.cpp" has the following code:

#if ARDUINO &gt;= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif


Naturally, I copied Arduino.h from the Arduino installation folder to my C++ project header directory. But for reasons I don't know, ARDUINO is apparently not greater than or equal to 100, so it attempts to include "WProgram.h." Because I cannot find this header file, I changed my code to only attempt to include Arduino.h.

#if ARDUINO &gt;= 100
 #include "Arduino.h"
#else
 #include "Arduino.h"
#endif


However, Arduino.h itself includes several header files, and I am not sure where I can find all the find them, or if it is even necessary to try to do so. I need to get my test code running, so I don't want to directly test it in the Arduino IDE yet. What can I do to overcome #include Arduino.h and #include WProgram.h?
The libraries from Adafruit and elsewhere assume you are using the Arduino IDE. If you choose not to use that you will have difficulties compiling your own code. The header files you ask about are in the IDE download. You can always grab a copy of that and put the appropriate .h files into your "include" search path.


  However, in my io.h file, there is a long list of #if defined (AVR_various_names).


Well, do a test compile using the Arduino IDE, using "verbose compiling" and see what defines are generated for your particular board (which you haven't mentioned). There won't be that many of them. Then you can put that on the build commands for your IDE.


  Or can I avoid all this and somehow create C++ classes independently?


You can create C++ classes inside the Arduino IDE. I don't see how this relates to your other issues.



The Arduino IDE basically generates build commands for avr-g++ - it isn't some horrible beast you should avoid using.