• 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: #define and if statements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #define and if statements


  • Subject: Re: #define and if statements
  • From: Kai Brüning <email@hidden>
  • Date: Sat, 27 Feb 2010 20:31:55 +0100

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.
>
> Adam
>
>
> On Sat, Feb 27, 2010 at 1:24 AM, Dave DeLong <email@hidden> 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:
>>
>> 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 the place where the #define will be used.
>>
>> Dave
>>
>> On Feb 26, 2010, at 11: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 ';' token
>>>
>>> #define IsDemo NO;
>>> #define IsDemo false;
>>> #define IsDemo 0;
>>>
>>>
>>> if (IsDemo) {
>>>  bla...
>>> }
>>>
>>> Same problem, when I try:
>>> #define FreeUpdateDaysAllowed 180;
>>> if (daysSoFar > FreeUpdateDaysAllowed)
>>>
>>>
>>> What am I doing wrong? Whats the right way to have a bool or int constant?
>>>
>>> Thanks,
>>> Adam
>>> _______________________________________________
>>>
>>> Cocoa-dev mailing list (email@hidden)
>>>
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >#define and if statements (From: Adam Gerson <email@hidden>)
 >Re: #define and if statements (From: Dave DeLong <email@hidden>)
 >Re: #define and if statements (From: Adam Gerson <email@hidden>)

  • Prev by Date: Re: Improving the User Experience for First Use of Downloadable Software
  • Next by Date: NSMenuItem Action
  • Previous by thread: Re: #define and if statements
  • Next by thread: Re: #define and if statements
  • Index(es):
    • Date
    • Thread