标题: error C202: sCode': undefined identifier [打印本页]

作者: 左右尤你    时间: 2023-11-4 13:37
标题: error C202: sCode': undefined identifier
求大神帮助一下啊 报错了
  1. #include <reg52.h>
  2. #include <intrins.h>
  3. unsigned char code SEGtable[]=
  4. {
  5.         0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00
  6. };
  7. unsigned char code keycodetable[]=
  8. {
  9.         0x11,0x12,0x14,0x18,0x21,0x22,0x24,0x28,0x41,0x42,0x44,0x48,0x81,0x82,0x84,0x88
  10. };
  11. void delay()
  12. {
  13.         unsigned char i;
  14.         for(i=0;i<200;i++);
  15. }
  16. unsigned char keys_scan()
  17. {
  18.         unsigned char scode,kcode,i,k;
  19.         P1=0xf0;
  20.         if((P1&0xf0)!=0xf0)
  21.         {
  22.                 delay();
  23.                 if((P1&0xf0)!=0xf0)
  24.                 {
  25.                         scode=0xfe;
  26.                         for(k=0;k<4;k++)
  27.                         {
  28.                                 P1=scode;
  29.                                 if((P1&0xf0)!=0xf0)
  30.                                 {
  31.                                         kcode=P1;
  32.                                         for(i=0;i<16;i++)
  33.                                         {
  34.                                                 if(kcode == keycodetable[i])
  35.                                                         return i;
  36.                                         }
  37.                                 }
  38.                                 else
  39.                                         sCode = _cro1_(scode,1);
  40.                         }
  41.         }
  42. }
  43.         return -1;
  44. }
  45. unsigned char switchkeyno(unsigned char temp)
  46. {
  47.         unsigned char keypadno;
  48.         switch(temp)
  49.         {
  50.                 case 0: keypadno = 7; break;
  51.                 case 1: keypadno = 7; break;
  52.                 case 2: keypadno = 1; break;
  53.                 case 3: keypadno = 10; break;
  54.                 case 4: keypadno = 8; break;
  55.                 case 5: keypadno = 5; break;
  56.                 case 6: keypadno = 2; break;
  57.                 case 7: keypadno = 0; break;
  58.                 case 8: keypadno = 9; break;
  59.                 case 9: keypadno = 6; break;
  60.                 case 10: keypadno = 3; break;
  61.                 case 11: keypadno = 11; break;
  62.                 case 12: keypadno = 12; break;
  63.                 case 13: keypadno = 13; break;
  64.                 case 14: keypadno = 14;        break;
  65.                 case 15: keypadno = 15; break;
  66.                 default:{}
  67.         }
  68.         return keypadno;
  69. }
  70. int main(void)
  71. {
  72.         unsigned char keyno = -1;
  73.         while(1)
  74.         {
  75.                 keyno = keys_scon();
  76.                 if(keyno != -1)
  77.                 {
  78.          P2 = SEGtable[switchkeyno(keyno)];
  79.                 }
  80.         }
  81. }
复制代码


联想截图_20231104133911.png (117.89 KB, 下载次数: 23)

联想截图_20231104133911.png

作者: zhuls    时间: 2023-11-4 14:26
sCode = _cro1_(scode,1);
sCode = _crol_(scode,1);
作者: Hephaestus    时间: 2023-11-4 14:40
c语言是区分大小写的,你只定义了scode,sCode是完全不同的另一个变量,你没有定义。
作者: chxelc    时间: 2023-11-4 15:43
板凳正解




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1