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