【MFC】error C4430: 缺少类型说明符 - 假定为 int 注意: C++ 不支持默认 int

1>d:\mt\mtupsmonitor\mtupsmonitor\Common.h(63): error C2146: 语法错误: 缺少“;”(在标识符“CString2string”的前面)
1>d:\mt\mtupsmonitor\mtupsmonitor\Common.h(63): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\mt\mtupsmonitor\mtupsmonitor\Common.h(63): warning C4183: “CString2string”: 缺少返回类型;假定为返回“int”的成员函数
1>d:\mt\mtupsmonitor\mtupsmonitor\Common.h(64): error C2061: 语法错误: 标识符“string”
1>d:\mt\mtupsmonitor\mtupsmonitor\Common.h(72): error C2143: 语法错误 : 缺少“;”(在“<”的前面)
1>d:\mt\mtupsmonitor\mtupsmonitor\Common.h(72): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\mt\mtupsmonitor\mtupsmonitor\Common.h(72): error C2238: 意外的标记位于“;”之前


总结了一下,主要有以下原因:

1、(此情况经常出现在大型工程项目中)如果存在两个类的头文件a.h和b.h,在a.h中有这样的语句:#include "b.h",在b.h文件中有这样的语句:#include "a.h"   且在一个类中有另一个类的对象时   那么就会出现这样的错误。

2、没有包含要定义的类的头文件。

3、项目中少加了宏定义,导致头文件重复定义或相应宏无法识别。

4、函数无返回类型的时候,可能也会导致这样的错误。

5、当有多个头文件时,顺序写反也可能导致相关的错误,其根本是头文件中的预编译语句被隐去了。

比如:

     #include <stdio.h>

     #include <Windows.h>   第二个

     #include <WinCrypt.h>    第三个

    #include <string.h>如果把第二个和第三个写反,一个宏定义就被#if给注了,就会出现类似错误
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值