| | |
External Delaration for An Array?
![]() |
•
•
Join Date: Jul 2008
Posts: 36
Reputation:
Solved Threads: 0
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!
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!
>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:
>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
Yep, you're required to specify all but the first dimension, even for an incomplete type. You need it in the definition too:
c Syntax (Toggle Plain Text)
/* .c file */ unsigned char jetmap[][3] = { /* ... */ }; /* .h file */ extern unsigned char jetmap[][3];
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.
![]() |
Other Threads in the C Forum
- Previous Thread: Dynamically allocating 2d arrays
- Next Thread: Sending "char" to "int" variable
| Thread Tools | Search this Thread |
* adobe ansi api array asterisks binarysearch calculate centimeter changingto char cm convert copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory fflush file fork forloop frequency givemetehcodez grade graphics gtkgcurlcompiling gtkwinlinux hacking highest histogram homework i/o inches infiniteloop input interest iso kernel keyboard km linked linkedlist linux linuxsegmentationfault list locate looping loopinsideloop. lowest match microsoft mqqueue mysql number open opendocumentformat owf pattern pdf performance posix power probleminc process program programming pyramidusingturboccodes radix read recv repetition research reversing scanf scheduling segmentationfault send sequential socket socketprograming stack standard string systemcall threads turboc unix user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h windowsapi






