• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Const help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Const help


  • Subject: Re: Const help
  • From: Nathan Day <email@hidden>
  • Date: Sat, 30 Oct 2004 13:17:54 +1000

In your header file declare them as

extern const int kTileSize;
extern const int kGridSizeX;
extern const int kGridSizeY;
extern const int kNumberOfTiles;

an then in your implementation file as

const int kTileSize = 32;//32
const int kGridSizeX = 19;//19
const int kGridSizeY = 16;//16
const int kNumberOfTiles = 4;//4


On 30/10/2004, at 12:03 AM, Killobit wrote:

hello

I'm trying to create a constant that can be used in 2 different classes but the compiler keeps giving me the following error

GokubanView.h:40: error: variable-size type declared outside of any function

where the line is:
int levelGrid[kGridSizeX][kGridSizeY];

I'm trying to define the constant in a file called globalConstants.h

like so:
#ifndef _globals_
#define _globals_
const int kTileSize = 32;//32
const int kGridSizeX = 19;//19
const int kGridSizeY = 16;//16
const int kNumberOfTiles = 4;//4
#endif

i've tried using
extern const int kGridSize = 19

but the compiler also complains saying something to the effect:
constant declared extern with initial value

basically what i want to be able to do is
in one class do the following:

@interface levelClass : Object
{
int levelData[kGridSizeX][kGridSizeY];
}

@end

and in another file:

GokubanView..m:

- (void)initializeLevel {
int i,j;
for(i = 0; i < kGridSizeX; i++) {
blah blah blah
levelData[i][j] = some value
}

any help would be greatly appreciated,

Eric

<NotACrackDealer> "Hello? Is this the hospital? I think my neighbor is dead.
Send an ambulance. His address? Uh...69.138.49.252. <click> Hello?"

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Const help (From: Killobit <email@hidden>)

  • Prev by Date: Re: Preventing Xcode to include header files
  • Next by Date: Re: KVO of nested objects
  • Previous by thread: Re: Const help
  • Next by thread: Thread Cancelation
  • Index(es):
    • Date
    • Thread