与#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

 

相关文章:

  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2021-09-06
  • 2021-12-11
  • 2022-01-30
猜你喜欢
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
相关资源
相似解决方案