External Delaration for An Array?

Reply

Join Date: Jul 2008
Posts: 36
Reputation: lehe is an unknown quantity at this point 
Solved Threads: 0
lehe lehe is offline Offline
Light Poster

External Delaration for An Array?

 
0
  #1
Nov 20th, 2008
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!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,625
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 715
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: External Delaration for An Array?

 
0
  #2
Nov 20th, 2008
>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:
  1. /* .c file */
  2. unsigned char jetmap[][3] = { /* ... */ };
  3.  
  4. /* .h file */
  5. 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] .
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 36
Reputation: lehe is an unknown quantity at this point 
Solved Threads: 0
lehe lehe is offline Offline
Light Poster

Re: External Delaration for An Array?

 
0
  #3
Nov 20th, 2008
Thank you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC