Compilation error from WProgram.h

I tried to implement the Morse code library in the learning/hacking section of the main website. This is my implementation.

The header:

 #ifndef yaymorse_h
 #define yaymorse_h
 
 #include "WConstants.h"
 class yaymorse{
     public:
         yaymorse(int pin);
         void dot();
         void dash();
     private:
         int _pin;
 };
 
 #endif

and the implementation:

 #include "yaymorse.h"
 #include "WProgram.h"
 yaymorse::yaymorse(int pin){
     pinMode(pin, OUTPUT);
     _pin = pin;
 }
 
 void yaymorse::dot(){
     digitalWrite(_pin,HIGH);
     delay(250);
     digitalWrite(_pin,LOW);
     delay(250);
 }
 
 void yaymorse::dash(){
     digitalWrite(_pin,HIGH);
     delay(1000);
     digitalWrite(_pin,LOW);
     delay(250);
 }

The code is identical to the morse code library available for download. However, both do not work. The following error is received when verifying any code I write with either library:

In file included from /Applications/IDEs/arduino-0015/hardware/cores/arduino/WProgram.h:4,

/Applications/IDEs/arduino-0015/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

/Applications/IDEs/arduino-0015/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

/Applications/IDEs/arduino-0015/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

In file included from /Applications/IDEs/arduino-0015/hardware/cores/arduino/WProgram.h:6,

How do I fix this? :-?

EDIT:

Argh, nevermind. I got rid of the #include "WConstants.h" from the header file, and got it to work. Is it possible for the tutorial to be changed to reflect that the inclusion of that particular line may cause compilation errors?

I'm glad you posted this, because It does not make any sense to me why removing WConstants.h would work.

I would never thought of this myself, thanks.

Is there anyone that could enlighten me and explain why this is?

WConstants.h includes wiring.h and it is that file when included in a sketch that causes the problem.
The errors are because wiring.h defines macros for abs and round that conflict with function names in a system header file called math.h
Avoid including wiring,h (or WConstants.h) prevents this problem.