I’m looking at some open source projects and I’m seeing the following:
NSLog(@"%s w=%f, h=%f", #size, size.width, size.height)
What exactly is the meaning of ‘#’ right before the size symbol? Is that some kind of prefix for C strings?
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.
The official name of
#is the stringizing operator. It takes its argument and surrounds it in quotes to make a C string constant, escaping any embedded quotes or backslashes as necessary. It is only allowed inside the definition of a macro — it is not allowed in regular code. For example:A related preprocessor operator is the token-pasting operator
##. It takes two tokens and pastes them together to get one token. Like the stringizing operator, it is only allowed in macro definitions, not in regular code.