| | |
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 |
#include * ansi array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram homework i/o ide inches include infiniteloop input interest intmain() iso keyboard km license linked linkedlist linux list looping lowest matrix meter microsoft mysql number oddnumber open opendocumentformat openwebfoundation pdf pointer posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard strchr string suggestions systemcall test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






