Reputation: 40329
I have tried this:
CGRectMake(0.0f, kFooBarHeight, 100.0f, 10.0f);
I get an error unexpected ';' before ')'
, and too few arguments for CGRectMake
. When I exchange this with:
CGFloat foo = kFooBarHeight;
CGRectMake(0.0f, foo, 100.0f, 10.0f);
then all is fine. Are constants not suitable to pass along as parameters?
Upvotes: 1
Views: 1448
Reputation: 4174
Change your
#define kFooBarHeight 100;
to
#define kFooBarHeight 100
Semicolons should not be used to terminate #defines unless you know for certain how it will be used.
Upvotes: 3
Reputation: 705
Without the kFooBarHeight definition it's impossible to give a good answer but I'm guessing you defined kFooBarHeight using a preprocessor definition? If so, best guess is you added a semicolon to the end. Your definition should look like this: #define kFooBarHeight 10
but you have set as: #define kFooBarHeight 10;
.
If what you have is the second definition when it replaced by the preprocessor you get:
CGRectMake(0.0f, 10;, 100.0f, 10.0f);
That's why your second example works correctly, it expands to:
CGFloat foo = 10;;
CGRectMake(0.0f, foo, 100.0f, 10.0f);
Again, this is just an educated guess, it's impossible to say without the actual definition of kFooBarHeight.
Upvotes: 15