typedef重复定义的一种解决方法

     与#define不同,typedef没有类似#undef的方法取消定义,如果两个库中同时使用typedef定义了某个类型,便会编译失败。

     一个解决方法是,在包含第二个库时使用#define将重复定义的类型名改掉。

     例如,如果头文件sm_system.h和math.h中均包含"typedef xxxx float_t"语句,那么使用如下的头文件包含方法:

#include "sm_system.h"

#define float_t ms_float_t
#include <math.h>
#undef float_t

 

posted @ 2017-06-11 15:13  死猫  阅读(8708)  评论(0编辑  收藏  举报