What is Wprogram.h library?

This is probably a really stupid question, but what is the purpose of Wprogram.h/arduino.h library?
I’ve searched on arduino site, but can’t think anything that explains what exactly these are for other than wprogram.h was replaced with arduino.h in IDE 1.0
Hope someone can enlighten me :slight_smile:

There is history of the arduino project not everyone was aware of or supposed to know. I only this much: this all started with some graduate student(s) that created the wiring platform and IDE, called wiring board and wiring "programming language". This project is still active with active users like the arduino project. Then the arduino folks decide to create the arduino project based on wiring project so they took the wiring IDE (which took from the original Processing IDE), including all the libraries etc. and created the first Arduino board (slightly different than wiring board, cheaper!) called it arduino. Arduino project has not very positively acknowledged the wiring project as the source of their project and wiring folks didn't take it very well.

Now, that WProgram.h, is a definition file created by and for the wiring project and board. That's why it has a W on it. It has been in Arduino IDE since its beginning and was replaced by Arduino.h only recently when Arduino 1.0 was released. Now all Arduino 1.0+ IDE will use Arduino.h and not WProgram.h so if you have that plus some other old stuff, you will have to make changes to work with Arduino 1.0+ IDE. That enough explaining for you?

I think so. So basically I most likely never need it since I dont plan to get ol "wiring" boards, right? :) Thank you!

If you are not going to use some libraries written for arduino 0022 then you will never need it.

bratan: I think so. So basically I most likely never need it since I dont plan to get ol "wiring" boards, right? :) Thank you!

Not exactly. If you want to compile sketches found on the net that predate the 1.0 release, they won't compile (because they expect Wprogram.h to be in your arduino library folders). This has nothing to do with Wiring boards. To use these, you should use ... the Wiring IDE, because the wiring boards are not calling their pins teh same way. Also not compatible with shields etc. See http://wiring.org.co/hardware/ for more info (if you're curious)

Also, when released, the 1.0 IDE had some bugs, so many people continued to (and some still) use 0022. So even "new" sketches on github for example can make use of Wprogram.h.

One way around this is to add a Wprogram.h file in your arduino directory with "#include arduino.h" as content. Or the opposite if you use 0022.

Yes. Liudr is correct in his answer about WProgram.h To incorporate the library in your code and avoid any discrepancies if some functions are predated, use:

if ARDUINO >= 100

include "Arduino.h"

else

include "WProgram.h"

endif

:)

I do encounter Arduino.h if I write a multiple file sketch. It does not know a number of standard 'things' which is solved by including Arduino.h

This is probably a really stupid question, but what is the purpose of Wprogram.h/arduino.h library?

There is history of the arduino project not everyone was aware of or supposed to know...

I suppose that liudr's answer is "correct", but I don't really see how it answers the original question...

Arduino.h (or WProgram.h in its previous naming) contains definitions and prototypes for the things that make up the "Arduino language" beyond what is standard C/C++. So it defines pinMode() as well as the INPUT and OUTPUT arguments that pinMode() accepts.

It also sucks in (vis nested includes) all of the other #include files that Arduino code might be expected to require, including the "avr/io.h" file that defines all the per-chip constants, "stdlib.h", "string.h", and "math.h" for standard C functions, and "binary.h" to get those B00101000 constants.

You can look at the file yourself, of course, if you want to know exactly what's there - it's in .../hardware/arduino/avr/cores/arduino/Arduino.h