Objective C - How to write a macro
I nee开发者_如何学运维d to write a multi-line macro. I need this because I must have partial code that has been "paste" into specific points in my code. How can I do this?
It's not really clear from your question what you actually want, but a plain multi-line macro is defined as follows:
#define FOO something; \
something_else;
Of course, beware of the if .. else
problem. If this is applicable to your case, you could wrap things into a do { ... } while(0)
construct. This will ensure that it's treated as a single statement.
#define FOO do \
{ \
something; \
something_else; \
} while (0)
Use the backslash character like in C.
#define NINE (3 \
+ 3)
as in ansi c: http://www.java2s.com/Code/C/Macro-Preprocessor/Definingamacrotocomparetwovalues.htm
精彩评论