forgets what a 'byte' is.

What would make the compiler forget ‘byte?’

union bfr {
byte asByte;
int asInt[4];
};

//C:\WINDOWS\TEMP\build22937.tmp/test.h:5: error: ‘byte’ does not name a type

The include file where byte is defined is not included would be my first thought.

I think it's supposed to be part of the default library. I didn't see any mention of a library in the reference.

Might want to look at wiring.h:

typedef uint8_t byte;

I think you have an installation problem… the following code compiles as-is (no includes) with no errors on Arduino IDE 0018 for me:

void setup() {

  union bfr {
    byte asByte[];
    int asInt[4];
  };

}

void loop() {
}

If you notice, BrettW, he was compiling a .h file, not a sketch.

Ooooooh, yeah I've had that problem before PaulS. What should we do?? :-/

.h files can include other .h files, and SHOULD if they need the definitions therein. Just put #include "WProgram.h"at the top of your file "test.h", and it should work OK. The compiler/includefiles are set up to not run into a problem if a file is included more than once (so you can include WProgram.h in both test.h and test1.h, and then include both test.h and test1.h in your sketch, and nothing bad will happen.)

"byte" is not a standard (C or C++ compiler-recognized) type; it's a convenience provided by the Arduino environment so that users don't have to deal with officious type-names like "uint8_t"...

Well, thank you very much. That did the trick.

This sounds suspiciously like a bug. Shouldn't that library be included by default?

Shouldn't that library be included by default?

It is, but not necessarily BEFORE your other .h files are included. IIRC, the include of WProgram.h happens before the first actual C statement in your sketch, rather than before the first pre-processor statement. I think this allows certain parameters in WProgram.h to be overridden if that happens to be needed...

WProgram.h is added to a sketch. If you need it in your library, you need to add it. Library writing is quite a bit different from sketch writing, as you are discovering.