library + WConstants.h question

Hi -

I went through the 'Morse' lib tutorial from the playground and it compiled fine. The Morse example uses #include of 'WConstants.h' in the Morse.h file and #include "WProgram.h" in the .cpp file.

When I try my own custom class though, if I don't #include 'WConstants.h' in my .cpp file I get compile errors of the sort below

lib/WConstants.h:185: error: 'uint8_t' does not name a type
lib/WConstants.h:186: error: 'uint8_t' does not name a type
/Applications/Wiring/Wiring 14/tools/avr/bin/../lib/gcc/avr/4.1.2/../../../../avr/include/stdlib.h:78: error: expected unqualified-id before 'int'

When I do '#include the WConstants.h' in my .cpp it seems to compile fine. Also, when I look at the combined code in the 'applet' folder, I see that some .h files are #included twice:

#include "WProgram.h"
void initSensor();
void displayLights();
void updateSensorStates();
#include "RPSprite.h"
#include "HardwareSerial.h"
#include "RPSprite.h"
#include "HardwareSerial.h"

Are either of these issues a cause for concern? I am getting some weirdness with using my class lib and trying to track down possible sources.

Oh - my work flow is as I tweak my lib code, I remove the .o file from the Library folder to force a recompile. Should I also be removing the 'applet' folder that resides in my working sketch folder?



Hi Roy,

uint8_t is defined in wiring.h, this file is included by a number of other h files such as Wprogram.h and wconstants.h.

Including h files in multiple places is not a problem. If they are properly formed (and all the arduino ones I have looked at are), the extra includes are ingnored . That's the purpose of expression like this you see at the start of h files:
#ifndef Wiring_h // only do stuff if this expression is not defined
#define Wiring_h // define the expression so any later includes can be ignored