Re: #define and if statements

2010-02-27 Thread Kai Brüning
A tip for the next time you have problems with macros: use Xcode’s Preprocess command (in the Build menu) to see your macros resolved. Helps a lot in such cases. Kai On 27.2.2010, at 07:37, Adam Gerson wrote: > Thanks! I can't believe I missed that. Its 1:35am here and its been a long > day.

Re: #define and if statements

2010-02-27 Thread Jens Alfke
I don't mean to play teacher's-pet, but the moderator did just post the list guidelines a few days ago, including "no plain C questions". There are better places to ask those, including stackoverflow.com. Also, a tip: If you ever have weird errors involving #defines, Xcode's "Preprocess" comman

Re: #define and if statements

2010-02-26 Thread Adam Gerson
Thanks! I can't believe I missed that. Its 1:35am here and its been a long day. Adam On Sat, Feb 27, 2010 at 1:24 AM, Dave DeLong wrote: > #define's are basically a simple find and replace, so if you do: > > #define IsDemo NO; > > and then do: > > if (IsDemo) { ... } > > It's going to become: >

Re: #define and if statements

2010-02-26 Thread Graham Cox
On 27/02/2010, at 5:22 PM, Adam Gerson wrote: > #define IsDemo NO; > What am I doing wrong? Leave out the semi-colon. #define is a macro, the complete text is simply substituted for the name before compilation even starts, so you have the equivalent of if(NO;){...} which is invalid syntax.

Re: #define and if statements

2010-02-26 Thread Roland King
.. oh and static BOOL IsDemo = NO; is a better idea anyway I think .. On 27-Feb-2010, at 2:22 PM, Adam Gerson wrote: > I have the following constant set up. I have tried all three of these > variations and none of them work in an if statement in cocoa. I get > error: expected `)' before ';'

Re: #define and if statements

2010-02-26 Thread Roland King
Take the ';' off the end of the #define, the replaced text is everything to the end of the line, remember #define is just a text expansion, so with this #define IsDemo NO; replaced in this if( IsDemo ) { you're doing this if( NO; ) { and that's your syntax error On 2

Re: #define and if statements

2010-02-26 Thread Dave DeLong
#define's are basically a simple find and replace, so if you do: #define IsDemo NO; and then do: if (IsDemo) { ... } It's going to become: if (NO;) { ... } See the problem? You've got a semicolon in there. Generally, you don't end a #define with a semicolon unless you want a semicolon in t

#define and if statements

2010-02-26 Thread Adam Gerson
I have the following constant set up. I have tried all three of these variations and none of them work in an if statement in cocoa. I get error: expected `)' before ';' token #define IsDemo NO; #define IsDemo false; #define IsDemo 0; if (IsDemo) { bla... } Same problem, when I try: #define Fr