delorie.com/archives/browse.cgi | search |
From: | Paul Shirley <Paul AT no DOT spam DOT please> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: [Q] array declaration |
Date: | Sat, 11 Oct 1997 13:53:43 +0100 |
Organization: | wot? me? |
Distribution: | world |
Message-ID: | <VBh$BHAXb3P0EwDR@foobar.co.uk> |
References: | <Pine DOT SGI DOT 3 DOT 91 DOT 971007161047 DOT 19768A-100000 AT atmosp DOT physics DOT utoronto DOT ca> |
<Pine DOT SUN DOT 3 DOT 91 DOT 971008110125 DOT 28262M-100000 AT is> | |
Reply-To: | Paul Shirley <Paul AT chocolat DOT obvious DOT fake DOT foobar DOT co DOT uk> |
NNTP-Posting-Host: | chocolat.foobar.co.uk |
Mime-Version: | 1.0 |
Lines: | 23 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
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.) --- Paul Shirley: my email address is 'obvious'ly anti-spammed
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |