Amazon.com Widgets To preprocess or not to preprocess?
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 22, 2013, 02:28:47 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  General Discussion
| | |-+  To preprocess or not to preprocess?
Pages: [1]   Go Down
Print
Author Topic: To preprocess or not to preprocess?  (Read 2164 times)
gwsounddsg
Newbie
*
Posts: 46






« on: March 03, 2012, 10:11:01 PM »

I am curious about the preprocessor and how the #define directive actually works.  Let's say I have something like this:

Code: (Objective-C)
 #define kTest (double) (4.0 * atan(1.0) * 0.5) 

When later in my code I use kTest, does it have to recalculate the value for kTest or does the preprocessor do the calculation and kTest is just passing the value?

GW
 
Logged
gwsounddsg
Newbie
*
Posts: 46






« Reply #1 on: April 12, 2012, 07:20:43 PM »

So after some research I found the answer to my question.  Using a  #define directive essentially inserts the code where the macro is located in your code.  So it would be better to do something like:

Code: (Objective-C)
 static double kTest (4.0 * atan(1.0) * 0.5); 

GW
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.