【问题标题】:Why are my variables reporting as "undeclared identifier" when compiling?为什么我的变量在编译时报告为“未声明的标识符”?
【发布时间】:2014-12-31 14:09:10
【问题描述】:

我有以下代码:

       for(int iY=0;iY<(Height-YRemainder);iY=iY+16);
        {
            for(int iX=0;iX<(Width-XRemainder);iX=iX+16);
            {
                if(Operation==BLACKNESS)
                {
                    Operation = WHITENESS;
                    PatBlt(DeviceContext, iX, iY, 16, 16, Operation);
                }
                else
                {
                    Operation = BLACKNESS;
                    PatBlt(DeviceContext, iX, iY, 16, 16, Operation);
                }
            }
            if(Operation == BLACKNESS)
            {
                Operation = WHITENESS;
                PatBlt(DeviceContext, Width-XRemainder,iY,16,16,Operation);
            }
            else
            {
                Operation = BLACKNESS;
                PatBlt(DeviceContext, Width-XRemainder, iY, 16, 16, Operation);
            }


        }

编译时,我收到针对 iX 和 iY 的每个 PatBlt 报告的未声明标识符。我是否误解了每个变量的范围是如何在这里工作的,或者我错过了什么?

提前致谢

【问题讨论】:

    标签: c variables scope


    【解决方案1】:

    你在 for 语句的末尾有分号,这会将它们变成单行语句:

    for(int iY=0;iY<(Height-YRemainder);iY=iY+16);
    

    变成

    for(int iY=0;iY<(Height-YRemainder);iY=iY+16)
    

    【讨论】:

      猜你喜欢
      • 2017-09-17
      • 1970-01-01
      • 2022-07-25
      • 2016-10-20
      • 1970-01-01
      • 2013-02-23
      • 2022-12-06
      • 2022-11-14
      • 2013-06-16
      相关资源
      最近更新 更多