Date: Fri, 23 Mar 2001 19:23:21 +0530 (IST) From: Mridul Muralidharan To: dummy_addressee AT hotmail DOT com cc: Djgpp mailing list Subject: Re: Extern int [][] In-Reply-To: <99fckc$h04$1@node17.cwnet.frontiernet.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Fri, 23 Mar 2001, Alexei A. Frounze wrote: > "Daniel Eliasson" wrote in message > news:_msu6.644$I81 DOT 6431 AT nntp1 DOT chello DOT se... > > Hi, I've got a little problem that I need some help with. Actually, there > > are two. > > > > Here goes: > > > > 1. In a function, I declare the following variables: > > > > const int GRIDSIZE = 128; > > int grid[GRIDSIZE][GRIDSIZE]; > > 1st of all, if you really want to have an array of adynamic size, use > malloc(),free(),realloc() and forget about the above stuff. If you don't > need arrays of variable size, define your GRIDSIZE as follows: > #define GRIDSIZE 128 > Actually ,AFAIK , const int var_name is better way to do the above as compared to #define in C++. also in C++ , u are encouraged to use const in the place of #define anyway. > > When I need to use it in another function, how do I get it with an extern > > keyword? I've tried extern int grid, extern int grid[][] and extern int > > grid[GRIDSIZE][GRIDSIZE] > > > > The last one works, but it seems as it declares a new local variable > called > > grid instead of giving me access to the one I want. > > How do I import it? > > "extern" doesn't create new variables. it helps to locate external stuff... right . > > 2. The compiler says that "storage size of `weaponCache' isn't constant" > > weaponCache is declared like this: > > > > const int MAXWEAPONS = 10; > > char *weaponCache[MAXWEAPONS]; when i tried out the above , i didn't get any such error ! (tried it on linux and djgpp ) Mridul Muralidharan S8 Electronics and Communication Regional Engineering College Calicut India ------------------------------------------------------------------------------ If the code and the comments disagree, then both are probably wrong. -- Norm Schryer All generalizations are false, including this one. -- Mark Twain /earth is 98% full ... please delete anyone you can. - fortune