作为C新手我想听听Macro“define”开发人员正在使用什么。我一直在思考把这些在头跳过冗长我已经习惯于:个人预处理器指令
#define TS_ typedef struct {
#define _TS(x) } x;
#define I(x)_ { int i; for (i = 1; i <= x; i++) {
#define _I } }
我可以添加这些宏内\ n \ t等?正如我想通过我的源代码减去额外包括:
#define TS_ typedef struct {\n
#define _TS(x) } x;\n
#define I(x)_ { int i;\n\tfor (i = 1; i <= x; i++) {\n
#define _I \t}\n}\n
这些工作?
ie:我可以使用协处理器将我的源代码替换为我的个人包含格式化的源代码,而不包含?
链接到良好的预处理器的提示和技巧也赞赏。
我不明白。为什么你想把空格放入宏?由于预处理源不会被人类看到(通常),因此它不会提高可读性。 – 2009-08-01 09:03:59
正如其他人所说,使用C预处理器试图重写C语法通常被认为是不好的形式。也取决于你如何做到这一点,你可能会在这里结束http://thedailywtf.com/Articles/The_Secret_to_Better_C.aspx – Falaina 2009-08-01 10:27:46