Hi,
I have an array. I put its definition in a .c file and externally delare it in a .h file like this:
//.c file
unsigned char jetmap[][]={
{0, 207, 255},
{0, 223, 255},
{0, 239, 255},
{0, 255, 255},
{16, 255, 239},
{32, 255, 223},
{48, 255, 207},
{64, 255, 191},
{80, 255, 175}
}
...
//.h file
extern unsigned char jetmap[][]; //missing subscript
// extern unsigned char ** jetmap; // redefinition; different types of indirection

As in the comment of the header file, both declarations are reported wrong by complier. How to delare the correct type of an array? Thanks in advance!

Recommended Answers

All 2 Replies

>extern unsigned char jetmap[][]; //missing subscript
Yep, you're required to specify all but the first dimension, even for an incomplete type. You need it in the definition too:

/* .c file */
unsigned char jetmap[][3] = { /* ... */ };

/* .h file */
extern unsigned char jetmap[][3];

>extern unsigned char ** jetmap; // redefinition; different types of indirection
Yep, the declaration doesn't match the definition. The type of jetmap in the definition is unsigned char (*)[3] .

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.