日期:2014-05-16  浏览次数:20679 次

linux下的编译问题,请帮忙解决!
../inc/typedef.h:59:   redefinition   of   `ENUM_SFN_SFN_OTD_TYPE '
../inc/typedef.h:59:   here   is   the   previous   declaration   of   `ENUM_SFN_SFN_OTD_TYPE '
../inc/typedef.h:61:   redefinition   of   `ENUM_T_CR_MAX_HYST '
../inc/typedef.h:61:   here   is   the   previous   declaration   of   `ENUM_T_CR_MAX_HYST '
../inc/typedef.h:63:   redefinition   of   `ENUM_TEMP_OFFSET1 '
../inc/typedef.h:63:   here   is   the   previous   declaration   of   `ENUM_TEMP_OFFSET1 '
../inc/typedef.h:65:   redefinition   of   `ENUM_TEMP_OFFSET2 '
../inc/typedef.h:65:   here   is   the   previous   declaration   of   `ENUM_TEMP_OFFSET2 '
../inc/typedef.h:67:   redefinition   of   `OPTION_BIT_32 '
../inc/typedef.h:67:   here   is   the   previous   declaration   of   `OPTION_BIT_32 '

以上只是其中的一部分,象“ENUM_T_CR_MAX_HYST”这样我整个工程里面只有一处定义,但是好像提示重复定义,不知道什么原因,哪位给解释一下。

------解决方案--------------------
头文件被#include了多次!

------解决方案--------------------
应该
#ifndef ***
#define ***
#else
#define ****
#endif
------解决方案--------------------
贴代码, 光这么说说不清楚.
看样子你这个应该不是宏, 是变量吧, 我估计是声明处没有加extern的原因吧.
------解决方案--------------------
redefinition,应该是在头文件中定义了全局变量吧?这种情况保护宏起不到作用的
头文件中最好不要定义变量而只是用extern声明,定义统一放在cpp中吧
------解决方案--------------------
被包含多次了,也会引起重新定义的
------解决方案--------------------
应该区别声明和定义的区别
2,要明白什么情况下使用
#ifdef _XXHEADER_H_
#define _XXHEADER_H_

// header place here

#endif
------解决方案--------------------
up
不会
------解决方案--------------------
把../inc/typedef.h贴出来让大家看看吧。