现在工程中有一个头文件,对各种变量进行定义。
test.h
union u_x{
u1_a;
u1_b
} ;
union u_xx{
u2_a;
u2_b;
};
现在我们需要对工程里的枚举进行扩展,有两种做法,
做法1: 修改test.h文件
union u_x{
u1_a,
u1_b,
u1_c,
} ;
union u_xx{
u2_a,
u2_b,
u2_c,
};
做法2: 通过包含另一个文件test_a.h来扩展
test.h
union u_x{
u1_a,
u1_b,
#define UNION_X
#include test_a.h
#undefine UNION_X
} ;
union u_xx{
u2_a,
u2_b,
#define UNION_XX
#include test_a.h
#undefine UNION_XX
};
test_a.h
#ifdef UNION_X
u1_c,
#endif
#ifdef UNION_XX
u2_c,
#endif
这样可以将扩展的部分从原原件中分离出来。
最后
以上就是难过小松鼠最近收集整理的关于define+include 文件的巧用的全部内容,更多相关define+include内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复