byte not supported in header file???

Today I was programming for arduino and I decided to create a global variable in a header file, and then include that header file in my main.pde.

In the header file, let's call it test.h if i declare:
int x = 2;
There are no compile errors.

But if the type is changed from int to byte:
byte x = 2;
There is a compile error: 'byte' does not name a type

If the declaration is made on the pde file everything compiles without any problem.

Is this a bug? Or am I missing something?

Can anyone enlight me?
Thanks for your time.

When compiling pde sketches the IDE links in some of the Arduino 'core' libraries, where byte is defined. You probably could just use standard C types that are 8 bits long, char? Or research the IDE build process to see which include files will pull in the byte type.

Lefty

And shouldn't the default libraries used be the same???

I had the same exact problem earlier today. I just used uint8_t instead of byte. After all, uint8_t (unsigned 8-bit integer) is the same as byte. I looked everywhere through the arduino core stuff to find how the type byte is defined, but to no avail. I was hoping to find the header file needed to be included so it would work...

So just replace "byte" with "uint8_t". That worked for me.

Here it says uint8_t does not name a type...

I've tried char, but it seems to not recognize binary input... (it seems that is for the same reason that won't recognize byte)

If someone knows which core libraries i shall include it would be great!

Thanks.

Put #include "WProgram.h"
at the top of your .h file.

Problem solved by westfw!!!

Thanks a lot!!!