How do #defines work in objective-c? I have a background in C/C++ and am now trying to pick up objecive-c. #defines don't seem to work in objective-c the same way they work in c and c++, where the compiler just replaces all references to the defines with what they are supposed to represent.
When I try to use #defines in objective-c they only work sometimes. Like when i do something like this;
#define NUMBER 5
int myArray[NUMBER];
I get compiler errors saying there is a square bracket missing, where if i use this line instead it works fine;
int myArray[5];
Surely these should both be the same thing?
Also if i try to use #define value in any sort of equations I get similar sort of compiler errors. This code wont work;
#define NUMBER 5
float var = NUMBER * 0.2;
where as this is fine;
float var = 5 * 0.2;
Anyone any idea why this might be, or how #defines are handled differently by the objective-c compiler. I'm using XCode by the way, just incase that makes a difference.