pgm_read_word reads long as 2 bytes

I have:

const long colorVals[] PROGMEM = { 0xF0F8FF, 0xFAEBD7, .....

Serial.println( (long)(pgm_read_word(&colorVals[0])) ); This returns the value of 0xF8FF

Serial.println( sizeof(pgm_read_word(&colorVals[0])) ); And surprisingly, this returns 2.

What am I doing wrong?

You do not read the documentation?

What am I doing wrong?

Casting a word (int) as a long doesn't make it so.

Taking the size of a function doesn't make sense.

sizeof(function()) returns the size of the return value of the function.

long lFunc() {
  return 2;
int iFunc() {
  return 1;
byte cFunc() {
  return 0;
void setup() {
  Serial.print(F("sizeof(cFunc()) "));
  Serial.print(F("sizeof(iFunc()) "));
  Serial.print(F("sizeof(lFunc()) "));
void loop() {}
sizeof(cFunc()) 1
sizeof(iFunc()) 2
sizeof(lFunc()) 4

You want pgm_read_dword(…)

Hmm. C++ could “fix” this…

Whandall: You do not read the documentation?

Never knew that it existed. Thanks