设为首页 加入收藏

TOP

C语言开发中常见报错的解决方案(三)
2019-06-16 22:07:59 】 浏览:234
Tags:语言 开发 中常 见报 解决方案
与形参类型不一致


error C2676: binary '<<' : 'class istream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator
error C2676: binary '>>' : 'class ostream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator
解决方案:“>>”、“<<”运算符使用错误,例如“cin<<x; cout>>y;”


error C4716: 'xxx' : must return a value
中文对照:(编译错误)函数 xxx 必须返回一个值
解决方案:仅当函数类型为 void时,才能使用没有返回值的返回命令。


fatal error LNK1104: cannot open file "Debug/Cpp1.exe"
中文对照:(链接错误)无法打开文件 Debug/Cpp1.exe
解决方案:重新编译链接


fatal error LNK1168: cannot open Debug/Cpp1.exe for writing
中文对照:(链接错误)不能打开 Debug/Cpp1.exe文件,以改写内容。
解决方案:一般是 Cpp1.exe 还在运行,未关闭


fatal error LNK1169: one or more multiply defined symbols found
中文对照:(链接错误)出现一个或更多的多重定义符号。
解决方案:一般与 error LNK2005 一同出现


error LNK2001: unresolved external symbol _main
中文对照:(链接错误)未处理的外部标识 main
解决方案:一般是 main 拼写错误,例如“void mian()”


error LNK2005: _main already defined in Cpp1.obj
中文对照:(链接错误)main 函数已经在 Cpp1.obj 文件中定义
解决方案:未关闭上一程序的工作空间,导致出现多个 main 函数


warning C4003: not enough actual parameters for macro 'xxx'
中文对照:(编译警告)宏 xxx 没有足够的实参
解决方案:一般是带参宏展开时未传入参数


warning C4067: unexpected tokens following preprocessor directive -expected a newline
中文对照:(编译警告)预处理命令后出现意外的符号-期待新行
解决方案:“#include<iostream.h>;”命令后的“;”为多余的字符


warning C4091: '' : ignored on left of 'type' when no variable is declared
中文对照:(编译警告)当没有声明变量时忽略类型说明
解决方案:语句“int ;”未定义任何变量,不影响程序执行


warning C4101: 'xxx' : unreferenced local variable
中文对照:(编译警告)变量xxx定义了但未使用
解决方案:可去掉该变量的定义,不影响程序执行


warning C4244: '=' : conversion from 'type1' to 'type2', possible lossof data
中文对照:(编译警告)赋值运算,从数据类型 1 转换为数据类型 2,可能丢失数据
解决方案:需正确定义变量类型,数据类型1为float或double、数据类型 2 为 int时,结果有可能不正确,数据类型 1 为 double、数据类型 2 为 float 时,不影响程序结果,可忽略该警告


warning C4305: 'initializing' : truncation from 'const double' to 'float'
中文对照:(编译警告)初始化,截取双精度常量为 float 类型
解决方案:出现在对 float 类型变量赋值时,一般不影响最终结果


warning C4390: ';' : empty controlled statement found; is this the intent?
中文对照:(编译警告)‘;’控制语句为空语句,是程序的意图吗?
解决方案:if 语句的分支或循环控制语句的循环体为空语句,一般是多加了“;”


warning C4508: 'xxx' : function should return a value; 'void' return type assumed
中文对照:(编译警告)函数 xxx 应有返回值,假定返回类型为 void
解决方案:一般是未定义 main 函数的类型为 void,不影响程序执行


warning C4552: 'operator' : operator has no effect; expected operator with side-effect
中文对照:(编译警告)运算符无效果;期待副作用的操作符
解决方案:例如“i+j;”语句,“+”运算无意义


warning C4553: '==' : operator has no effect; did you intend '='?
中文对照:(编译警告)“==”运算符无效;是否为“=”?
解决方案:例如 “i==j;” 语句,“==”运算无意义

warning C4700: local variable 'xxx' used without having been initialized
中文对照:(编译警告)变量 xxx 在使用前未初始化
解决方案:变量未赋值,结果有可能不正确,如果变量通过 scanf 函数赋值,则有可能漏写“&”运算符,或变量通过 cin 赋值,语句有误


warning C4715: 'xxx' : not all control paths return a value
中文对照:(编译警告)函数 xxx 不是所有的控制路径都有返回值
解决方案:一般是在函数的 if 语句中包含 return 语句,当 if 语句的条件不成立时没有返回值


warning C4723: potential divide by 0
中文对照:(编译警告)有可能被 0 除
解决方案:表达式值为 0 时不能作为除数


warning C4804: '<' : unsafe use of type 'bool' in operation
中文对照:(编译警告)‘<’:不安全的布尔类型的使用
解决方案:例如关系表达式“0<=x<10”有可能引起逻辑错误

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇linux 线程基础 下一篇nginx中共享内存的使用

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目