“was not declared in this scope”是一个错误信息,在编译的时候会遇到。其含义为标识符在其出现的地方是未被定义的。

出现该错误的时候,会同时把未定义的变量名显示出来。比如如下程序:

int main()
{
    printf("%d",i);//这个i是没定义的。
}

就会显示一个'i' was not declared in this scope或者类似的错误信息出来。

对于变量和函数,如果未定义都会出现这个错误。

该错误出现时,需要根据出现该错误的行号及名称,查找对应名称变量或函数的作用,一般有如下几种可能:

1 忘记定义。写代码的时候疏忽了,导致一些变量直接使用但没有定义。只要对应定义相应的函数或变量即可。

2 拼写错误。写代码的时候,敲错了字符。比如sum敲成了Sum, average敲成averge等。对应修改即可。

3 作用域不正确。在超出变量和函数的作用域部分使用了该变量或函数。需要通过定义位置,或增加声明的手段,加大变量的作用域使其包含引用位置。

was not declared in this scope的更多相关文章

  1. error: 'LOGE' was not declared in this scope

    移植了下HAL,发现编译出现如下错误 error: 'LOGE' was not declared in this scope 比较了一下android4.1的 system/core/include ...

  2. c++ - fcgio.cpp:50: error: 'EOF' was not declared in this scope - Stack Overflow

    c++ - fcgio.cpp:50: error: 'EOF' was not declared in this scope - Stack Overflow fcgio.cpp:50: error ...

  3. 【QT】error: 'SIGNAL' was not declared in this scope

    error: 'SIGNAL' was not declared in this scope  未在此范围内声明. connect(ui->Btnshowhello,SIGNAL(clicked ...

  4. 【error】'isnan' was not declared in this scope

    error问题 'isnan' was not declared in this scope isnan在cmath中被取消宏定义: // These are possible macros impo ...

  5. [Error] 'exit' was not declared in this scope的解决方法

    新手刚开始用Linux和c++写程序,可能会出现下面的错误 error: ‘exit’ was not declared in this scope 解决方法是 添加 #include <cst ...

  6. 解决Cygwin编译cocos2dx 遇到的 error: 'UINT64_C' was not declared in this scope 问题

    环境工具:Win10.VS2013.cocos2d-x-2.2.6.Cygwin.ADT 问题来源:写了一个小游戏,VS2013上运行成功,就尝试着打包apk,项目导入到ADT里面,添加了cocos2 ...

  7. 编译是报error: 'EVNET_COME_TO_FOREGROUND' was not declared in this scope

    Compile++ thumb  : game_shared <= main.cpp jni/hellocpp/main.cpp: In function 'void Java_org_coco ...

  8. 调用ffmpeg库编译时出现common.h:175:47: error: 'UINT64_C' was not declared in this scope

    解决办法 出现错误:jni/ffmpeg/libavutil/common.h:175:47: error: 'UINT64_C' was not declared in this scope 解决: ...

  9. ‘close’ was not declared in this scope

    ‘close’ was not declared in this scope ‘read’ was not declared in this scope ‘sysconf’ was not decla ...

随机推荐

  1. 如何打开VPK文件?里面究竟有什么?

    在DOTA2游戏目录下有一类VPK文件,如何打开VPK文件? 下载http://nemesis.thewavelength.net/index.php?p=26,安装完成后即可打开. 打开dota 2 ...

  2. 【BZOJ】3993: [SDOI2015]星际战争

    题意 \(m\)个人\(n\)个物品,第\(i\)个物品生命值为\(A_i\),第\(i\)个人每秒可以减少一个物品\(B_i\)的生命值,给出一个\(m \times n\)的矩阵,如果\(i\)行 ...

  3. msql数据迁移,myisam及innoDB

    直接迁移数据库文件. 一.MySQL数据库文件介绍 MySQL的每个数据库都对应存放在一个与数据库同名的文件夹中,MySQL数据库文件包括MySQL所建数据库文件和MySQL所用存储引擎创建的数据库文 ...

  4. Javascript学习之无缝滚动

    无缝滚动Javascript: <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...

  5. js 中将日期转换为星期需要注意的

    new Date(strDate); 中strDate需要是1998/10/30这样的格式,如果是1998-10-30的格式,不一定旧版本的web能兼容

  6. Mac OS X:禁止崩溃报告-CrashReport

    Mac OS X:禁止崩溃报告 崩溃报告就是CrashReport 至于官方的有关CrashReport的文档在Technical Note TN212 . 一般的默认情况下,当一个应用程序因为各种原 ...

  7. SMTP Error: Could not connect to SMTP host

    PHPMailer是一个非常棒的开源邮件类,使用也非常简单,但是对于虚拟主机来说,往往要受到各种限制.刚才我在虚拟主机上使用PHPMailer就遇到一个“SMTP Error: Could not c ...

  8. 【转】监听按钮除OnClick外其他事件的方法,附简易改编的UIButton类

    http://lib.csdn.net/article/unity3d/38463 作者:IceFantasyLcj 大家好,我是雨中祈雨.一直以来,CSDN都是我最好的编程助手.这是我在CSDN的第 ...

  9. js获取当前时间戳 不需毫秒数

    var timestamp = Date.parse(new Date())/1000;

  10. (分享)java向MySQL插入当前时间的四种方式和java时间日期格式化的几种方法(案例说明)

    原文地址 http://blog.csdn.net/yangkai_hudong/article/details/18705713