objective c - C preprocessor on Mac OSX/iPhone, usage of the '#' key? -
I'm looking at some open source projects and I'm looking for the following:
NSLog (@ "% sw =% f, h =% f", #size, size.width, size.height) Right before '#' means what size symbol ? Is there a prefix for C strings?
The official name is # stringing operator . It takes its arguments and surrounds it in quotation marks, to stabilize the string, save any embedded quotation or backslash as necessary, it is allowed within the macro definition - it is not allowed in regular code. For example:
// This is not legal const is char * str = #test // It is ok # defined STRINGIZE (x) #x const char * str1 = STRINGIZE (test ); // str1 = "test" equals; Const four * str2 = STRINGIZE (test2 "a \"); // str2 = "test2 \" a \\\ ""; A related preprocessor operator token-pasteing operator ## . Takes two tokens and pastes them together to get a token. Like a stringing operator, it is only allowed in macro definitions, not in regular code.
// This is not legal C int foobar = 3; Int x = foo ## times; // it's ok # tokenpeste (x, y) x ##Y int fobar = 3; Int x = tokenpeste (FU, bar); // X = equal to October;
Comments
Post a Comment