#include <stdio.h>
typedef unsigned char uint8_t;
// I want this at the end of the file
//static const uint8_t hello[] = { 'H','e','l','l','o',' ','W','o','r','l','d','!','\0'};
int main()
{ // how do I declare a forward reference to 'hello' here?
printf("%s\n", hello);
return;
}
// but down here, the linker can't resolve it
static const uint8_t hello[] = { 'H','e','l','l','o',' ','W','o','r','l','d','!','\0'};
Error C2065 'hello': undeclared identifier
For cosmetic reasons, I would like to put my large, static data tables at the end of my c source file. But how do I reference it? I have used a forward reference in a function to resolve functions that appear later in the file, but static variables are giving me a headache. I tried extern (as a last hope,) but the linker looks outside of the module (which makes sense,) but won't resolve to the darn variable just a few lines past the function that needs it. Is this a C limitation (I've tried this on two compilers,) or am I just missing something incredibly obvious?