KEIL for C51 并且有一些错误的问题,比如 syntax error near unsigned

KEIL for C51 and have some problems with error like syntax error near unsigned

我正在使用 Keil 开发 80C51,我使用 C51 进行编码。但是,我在编译时遇到了一些问题。我的代码如下:

#include <reg51.h>

#define uchar unsigned char
#define LED P2
sbit SH=P0^0;
sbit DATA=P3^0;
sbit CLK=P3^1;


void main()
{
  SCON=0x10;
    uchar a,i,j;
    while(1){
        a=0;
        SH=0;
        SH=1;
        for (i=0;i<8;i++){
            CLK=0;
            for (j=0;j<500;j++);
            DATA=0;
            CLK=1;
            for (j=0;j<500;j++);
            a=a<<1;
            a=a+(uchar)DATA;
        }
        LED=a;
    }
}

但编译器显示 lab7.c(13):错误 C141:'unsigned' 附近的语法错误。我不知道为什么会这样!非常感谢!

在函数开头的任何其他代码之前声明您的变量:

void main()
{
    uchar a,i,j;
    SCON=0x10;
    while(1){ 
    /* ... */

这是一个旧的 C 编译器限制,在 Keil C51 中从未被删除。