【Linux】【Debug】编译错误error: two or more data types in declaration specifiers

在项目开发时,遇到编译出错,看提示是重复的定义,错误信息如下:

In file included from ./include/wrn/wm/common/wm.h:176,

                 from ./include/wrn/wm/http/httpLib.h:55,
                 from ./include/wrn/wm/common/wmAuth.h:17,
                 from src/common/wmAuth.c:49:
./include/wrn/wm/common/wmData.h:241: error: two or more data types in declaration specifiers
./include/wrn/wm/common/wmData.h:241: warning: useless type name in empty declaration
./include/wrn/wm/common/wmData.h:242: error: two or more data types in declaration specifiers
./include/wrn/wm/common/wmData.h:242: warning: useless type name in empty declaration
src/common/wmAuth.c: In function 'wm_string_getCode':
src/common/wmAuth.c:816: warning: comparison between pointer and integer
src/common/wmAuth.c: In function 'wmAuthSetNewCookie':
src/common/wmAuth.c:2323: warning: passing argument 2 of 'wmAUTHGetClientCookie' from incompatible pointer type
src/common/wmAuth.c:2324: warning: passing argument 3 of 'httpMimeOutCookieSet' from incompatible pointer type
make[1]: *** [src/common/wmAuth.o] Error 1

make: *** [webserver_build] Error 2


网上查看过,说是加分号,和其他头文件存在相同的定义,但是查找过,本地文件目录和交叉编译工具链中的头文件,都没有发现相同的定义:

./include/wm_options.h:typedef int sbyte4;
./include/wrn/wm/backplane/wmbLib.h:typedef int WMB_RID_T;
./include/wrn/wm/backplane/wmbLib.h:typedef int WMB_DOMAIN_T;
./include/wrn/wm/backplane/wmb.h:typedef int     WMB_HASH_HINT_T;
./include/wrn/wm/backplane/wmb.h:typedef int     WMB_ROLES_T;
./include/wrn/wm/backplane/wmb.h:typedef int     WMB_RESOURCE_ID_T;
./include/wrn/wm/backplane/wmb.h:typedef int     WMB_ARCHIVE_TYPE_T;
./include/wrn/wm/backplane/wmb.h:typedef int     WMB_CMD_T;
./include/wrn/wm/common/wmnet.h:typedef int                 OS_SOCKET_T;
./include/wrn/wm/common/wmnet.h:typedef int                 OS_SOCKET_T;
./include/wrn/wm/common/wmnet.h:typedef int                 OS_SOCKET_T;
./include/wrn/wm/common/wmnet.h:typedef int                 OS_SOCKET_T;
./include/wrn/wm/common/wmnet.h:typedef int                 OS_SOCKET_T;
./include/wrn/wm/common/wm.h:typedef int sbyte4;
./include/wrn/wm/common/wmos.h:typedef int     OS_THREAD_T;
./include/wrn/wm/common/wmos.h:typedef int     OS_SEM_T;
./include/wrn/wm/common/wmos.h:typedef int     OS_MSGQ_T;
./include/wrn/wm/common/wmos.h:typedef int     OS_PIPE_T;
./include/wrn/wm/common/wmos.h:typedef int     OS_TIME_T;
./include/wrn/wm/common/wmos.h:typedef int     SHARED_DATA_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_SEM_T;
./include/wrn/wm/common/wmos.h:typedef int               OS_MSGQ_T;
./include/wrn/wm/common/wmos.h:typedef int               OS_PIPE_T;
./include/wrn/wm/common/wmos.h:typedef int             SHARED_DATA_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_SEM_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_MSGQ_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_PIPE_T;
./include/wrn/wm/common/wmos.h:typedef int             SHARED_DATA_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_MSGQ_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_PIPE_T;
./include/wrn/wm/common/wmos.h:typedef int             SHARED_DATA_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_ARG_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_THREAD_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_PIPE_T;
./include/wrn/wm/common/wmos.h:typedef int             OS_ARG_T;
./include/wrn/wm/common/wmos.h:typedef int             SHARED_DATA_T;
./include/wrn/wm/common/wmos.h:      typedef int OS_MSGQ_T;
./include/wrn/wm/common/wmos.h:typedef int SD_ID;
./include/wrn/wm/common/wmData.h:typedef int     CompareType;
./include/wrn/wm/common/wmData.h:typedef int     STATUS;
./include/wrn/wm/common/wmData.h:typedef int     BOOL;
./include/wrn/wm/common/zlib/vxWorks/zconf.h:typedef int   FAR intf;


查看提示错误的地方,是一个类型的定义:

typedef int     STATUS;;
typedef int     BOOL;;


修改成:

#ifndef STATUS
#define STATUS int
#endif
#ifndef BOOL
#define BOOL int
#endif



### 解决 `mex` 命令行错误:声明说明符中存在两个或更多数据类型 当遇到 `error: two or more data types in declaration specifiers` 的问题时,这通常意味着在同一变量声明中指定了多个不兼容的数据类型。这种错误常见于混合使用不同的存储类修饰符、类型限定符或其他类型的声明符。 对于此类错误的具体解决方案如下: #### 修改代码中的声明语句 确保每个变量仅有一个明确的数据类型定义。例如,在 C 或 C++ 中不应同时指定两种不同类型的修饰词给同一个变量。以下是修正后的代码片段示例[^1]: ```c // 错误示范 int static myVar; // 这里包含了 int 和 static 作为不同类型描述符 // 正确做法之一 static int myVar; ``` 如果是在编写 MEX 文件并遇到了上述语法上的编译错误,则应仔细检查源文件内的所有函数签名以及全局/局部变量的定义部分,移除任何重复或冲突的数据类型关键字组合。 另外值得注意的是,有时这类问题也可能源于第三方库头文件引入不当造成的命名空间污染等问题,因此建议开发者们也关注项目依赖关系管理方面的工作。 关于 MATLAB 下通过 `mex` 编译外部语言扩展模块时所面临的其他潜在障碍,如找不到支持的编译器环境等状况,请参照相关文档配置合适的开发工具链设置[^2][^3]。 最后,针对特定版本的 GCC/G++ 可能存在的选项识别失败情况(比如 `-std=c++11`),可以尝试调整编译参数或者切换到更稳定的编译器版本来规避此问题[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值