Mail Archives: djgpp/1997/10/14/18:01:16
Paul Shirley (Paul AT no DOT spam DOT please) wrote:
: In article <Pine DOT SUN DOT 3 DOT 91 DOT 971008110125 DOT 28262M-100000 AT is>, Eli Zaretskii
: <eliz AT is DOT elta DOT co DOT il> writes
: >There are other solutions, but none of them is elegant. This happens
: >to be one of the ugliest problems in C.
:
: The 'elegant' solution is to #define the array size in a header (the
: same one you declare the array seems a good idea;) then use it in both
: the declaration and definition of the array.
:
: so..
: #define MYSIZE (280)
: extern char myarray[MSYIZE];
:
: ...later...
: #include <the header>
: char myarray[MYSIZE];
:
: This guarantees that all references to myarray see the same sized array.
: (And makes sure that make will keep all uses in sync as a bonus.)
Or, for the truly paranoid:
In the header:
#define MY_ARRAY_SIZE (260)
typedef char MyArrayType[MY_ARRAY_SIZE];
extern MyArrayType myArray;
Somewhere in the source which includes this header:
MyArrayType myArray;
---------------------------------------------------------------------
| Craig Berry - cberry AT cinenet DOT net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
- Raw text -