Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 6, 2010, 01:46 AM   #1
BadWolf13
macrumors 6502
 
Join Date: Dec 2009
What kind of #if(compiler if) statements are available?

I hope I explained that well, but I'm talking about the #if statements that you can put into code, which tells the compiler to only compile a section of code if the condition is met. I've noticed a bunch in the Apple-provided headers, and I'm wondering, is there some kind of resource about what kind of conditions are available to put into these compiler statements?
BadWolf13 is offline   0 Reply With Quote
Old Nov 6, 2010, 02:22 AM   #2
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
All the standard C preprocessor directives should be available, including #if, #ifdef, #ifndef, #else, #elif and #endif. I don't think there's much that applies in an Objective-C context that would be different than in a straight C context.

http://en.wikipedia.org/wiki/C_preprocessor

EDIT: You'll notice there are some restrictions, for example you can't evaluate expressions using strings or floats, generally you can do that before the directive by defining a token and using #ifdef, or using an integer expression with #if.
__________________
Go outside, the graphics are amazing!

Last edited by HiRez; Nov 6, 2010 at 02:28 AM.
HiRez is offline   0 Reply With Quote
Old Nov 6, 2010, 10:22 AM   #3
BadWolf13
Thread Starter
macrumors 6502
 
Join Date: Dec 2009
Thank you, I didn't know the term preprocessor, and that's exactly what I was looking at, but I don't think I explained my question very well. It's not the different preprocessor directives that I'm looking for, it's more the different expressions that I can put into a preprocessor #if statement. For example, in foundation.h, there's a conditional compilation based on the statement;

Code:
#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || TARGET_OS_WIN32
The expressions used in this condition must have been defined at some point, so I'm wondering how I'm to know what kind of expressions/macros/constants I can use there. Is there some kind of listing, or guide to working with conditionals in XCode?

Last edited by BadWolf13; Nov 6, 2010 at 12:30 PM.
BadWolf13 is offline   0 Reply With Quote
Old Nov 6, 2010, 11:42 PM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
You can command-click those in Xcode to find out where they're defined, which is:

/usr/include/TargetConditionals.h

Also see
/usr/include/AvailabilityMacros.h
kainjow is offline   0 Reply With Quote
Old Nov 7, 2010, 12:06 PM   #5
BadWolf13
Thread Starter
macrumors 6502
 
Join Date: Dec 2009
Thanks, that's a good idea, unfortunately when I ctrl-click on the macro, the "Jump to Definition" is greyed out? Could there be a setting in XCode that's preventing me from using this?

Also, a spotlight search won't find either of those two files that you listed. Back when I used Windows, there were "hidden files", does OXS do anything like that?
BadWolf13 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
What kind of battery life life are you getting on 3.0? Renegade89 iPhone 3 Jun 15, 2009 09:35 PM
what kind of jobs are available for a BIO major???>>> rex-craft7 Community Discussion 2 Nov 9, 2008 10:33 AM
What kind of statement does the iPhone make? wonderbread57 iPhone 44 Aug 6, 2008 01:09 PM
What kind of speakers are connected to your Mac? Gymnut Macintosh Computers 44 May 1, 2003 04:13 PM
what kind of toilet paper are you using? vollspacken Community 33 Mar 18, 2003 01:46 AM


All times are GMT -5. The time now is 10:47 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC