Very odd "not declared in this scope" error occurrence

Hmm, well it seems this is the perennial question. :confused:

I've developed a basic RTC clock on a Teensy 2.0 which works by displaying a series of bitmapped numbers. Each number is declared using the usual:

const uint8_t char_0[] PROGMEM={
0xE0, 0xF8, 0xFC, 0xFE, 0xFE, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0xFE, 0xFE, 0xFC, 0xF8, 0xE0,   // 0x0010 (16) pixels
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,   // 0x0020 (32) pixels
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,   // 0x0030 (48) pixels
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,   // 0x0040 (64) pixels
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,   // 0x0050 (80) pixels
0x07, 0x1F, 0x3F, 0x7F, 0x7F, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0x7F, 0x7F, 0x3F, 0x1F, 0x07,   // 0x0060 (96) pixels
};

....this has been working fantastically until today when I decided to try adding in a new series of bitmaps for smaller characters representing seconds:

const uint8_t char_0_small[] PROGMEM={
0xFE, 0xFF, 0x03, 0x03, 0xFF, 0xFE, 0x00, 0x00, 0x7F, 0xFF, 0xC0, 0xC0, 0xFF, 0x7F, 0x00, 0x00,
};

Now when I compile the sketch I get the dreaded (snipped for brevity):

i2c_clock: In function 'void loop()':
i2c_clock:191: error: 'char_0_small' was not declared in this scope
       myOLED.drawBitmap(clockCentre+5+charSpacing, 16, char_0_small, 16, 48);

                                                        ^

i2c_clock:195: error: 'char_1_small' was not declared in this scope
       myOLED.drawBitmap(clockCentre+5+charSpacing, 16, char_1_small, 8, 48);

                                                        ^

This doesn't seem to add up. I'm not sure what changes have occurred to warrant this error. It seems a very inconsistent error to have crop up!

It seems likely that char_0_small wasn't declared in scope.
Impossible to tell from the snippet posted, but I'd trust the compiler.

Thanks AWOL. I didn't want to post the entire graphics.c file since it's a series of the same thing. I realised that it was my stupidity that was at fault (or was in fact working fully?):

extern uint8_t char_colon[];
extern uint8_t char_0[];
extern uint8_t char_1[];
extern uint8_t char_2[];
extern uint8_t char_3[];
extern uint8_t char_4[];
extern uint8_t char_5[];
extern uint8_t char_6[];
extern uint8_t char_7[];
extern uint8_t char_8[];
extern uint8_t char_9[];
extern uint8_t char_0_small[];
extern uint8_t char_1_small[];
extern uint8_t char_2_small[];
extern uint8_t char_3_small[];
extern uint8_t char_4_small[];
extern uint8_t char_5_small[];
extern uint8_t char_6_small[];
extern uint8_t char_7_small[];
extern uint8_t char_8_small[];
extern uint8_t char_9_small[];

Still not enough of your sketch showing to reproduce the problem and search for a solution.

Look for use of "#extern" in your sources/libraries. That might be necessary to reference a C++ declaration fro a C source file or vice-versa.

This was exactly my problem. They were declared externally, however since I am new to programming Arduinos I totally forgot the external reference declarations. Schoolboy error, however I hope that this helps other people figure out the cause of this common error message in similar instances.

The snippet of code above shows the additional EXTERN declarations made to fix my problem ("extern uint8_t char_0_small[];").

Thanks for dropping in to see me embarrass myself, guys.