I have found this macro while digging in the source code of tweejump game.
#define ccp(__X__,__Y__) CGPointMake(__X__,__Y__)
For me cpp it is just alias to CGPointMake. Why is needed this ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
#ifndef DEBUG#define ccp(__X__,__Y__) CGPointMake(__X__,__Y__)#else#define ccp(__X__,__Y__) myassert2(((__X__) > 0),((__Y__) > 0), \CGPointMake(__X__,__Y__))#endifWhy would we want to do that? We can get the error for the line of source code which has a bug:
BTW, in general it is safer for a macro to always wrap the arguments in parenthesis:
but as jamesdlin pointed out, in this case of a function call, it doesn’t matter.
IMHO it is better to have a ‘rule’ that is safe, easy to explain and remember, and only vary away for strong reason, rather than have a more complex rule. After all, there are more interesting problems to solve (in my code) than whether or not to wrap a macro’s arguments in parenthesis 🙂
(I am especially mindful of simple rules due to a recent BBC Horizon program which offered evidence that humans can not successfully think about three things at once!-(
(HELP! What is the easy way to format C preprocessor source code like
#if ...? the {} didn’t work, back ticks didn’t work, 4 leading spaces didn’t work. They all eat some of the leading#characters)