标题: main.c(4): error C129: missing ';' before 'i'这个究竟是什么问题啊,求解答 [打印本页]

作者: 龚芳平    时间: 2022-2-14 21:36
标题: main.c(4): error C129: missing ';' before 'i'这个究竟是什么问题啊,求解答
#define LED_L16 P0
#define LED_H16 P2
#define LED_C0L P1
uchar i,j;
uchar s;
uchar time;
uchar start;
uint code aFont[4][32]=
{
0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0x88,0xF8,0x00,0x00,0x00,0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0x7F,0x88,0x88,0x88,0x88,0x9F,0x80,0xF0,0x00
},
{
0x80,0x82,0x82,0x82,0x82,0x82,0x82,0xE2,0xA2,0x92,0x8A,0x86,0x82,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00
},
{
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,0x04,0x04,0x04,0x04,0x040x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00
},
{
0x00,0xFE,0x22,0x5A,0x86,0x10,0x0c,0x24,0x24,0x25,0x26,0x24,0x24,0x14,0x0c,0x00,0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,0x00
};
void main(void)
{
        LED_L16=0;
        LED_H16=0;        
        while(1)
        {
                Leddis(1);
                Leddis(2);
                Leddis(2,8);
                LeftC(4,8);
        }
        
}
void delay(uint t)//void
{
                while(t--);
}
void Leddis(uchar p)//void
{
                for(time=0;time<100;time++)
                        
        {               
                        s=0;
                  for(j=(p-1)*2;j<(p-1)*2+2;j++)
                {
                                for(i=0;i<16;i++)
                        {
                                        LED_COL=s;
                                        LED_L16=aFont[j][ i];
                                        LED_H16=aFont[j][i+16];
                                        delay(40);
                                        LED_L16=0;
                                        LED_H16=0;
                                        delay(2);
                                        s++;
                        }
                }                        
        }
}
void RightJ(uchar num,uchar movecol)//void
{
        start=16*num-movecol;
                while(1)
                {
                for(time=0;time<100;time++)
                        {
                                s=start;
                                for(j=0;j<4;j++)
                                {
                                        for(i=0;i<16;i++)
                                {
                                        LED_COL=s;
                                        LED_L16=aFont[j][ i];
                                        LED_H16=aFont[j][i+16];
                                        delay(40);
                                        LED_L16=0;
                                        LED_H16=0;
                                        delay(2);
                                        s++;        
                                        if(s>31) break;
                                }
                                if(s>31) break;
                        }
                        if(start>0)
                        {
                        start-=movecol;
                        }
                        else
                        {
                                break;
                        }
                }
        }
}
void RightC(uchar num,uchar movecol)//void
{
        uchar col=movecol;
        uchar n=0;
        uchar count=0;
                while(count<16*num/movecol)
                {
                for(time=0;time<100;time++)
                        {
                                s=0;
                                start=col;
                                for(j=n;j<4;j++)
                                {
                                for(i=start;i<16;i++)
                                {
                                LED_COL=s;
                                LED_L16=aFont[j][ i];
                                LED_H16=aFont[j][i+16];
                                        delay(40);
                                        LED_L16=0;
                                        LED_H16=0;
                                        delay(2);
                                        s++;        
                                        if(s>31) break;
                                }
                                start=0;
                                if(s>3)break;
                        }
                                count++;
                                co1+=movecol;
                                if(col==16)                        
                        {
                                n++;
                                col=0;
                        }
                }
        }
}
最后测试有错,下面显示的是这样
compiling main.c...
main.c(4): error C129: missing ';' before 'i'
main.c - 1 Error(s), 0 Warning(s).


作者: TEC    时间: 2022-2-14 22:13
uchar 没有被定义吧。
作者: 13205495918    时间: 2022-2-15 08:55
uchar这个一般情况下是说的unsigned char的缩写,这个需要你自己定义,一般是宏定义#define uchar unsigned  char
作者: 天ノ忆    时间: 2022-2-15 15:19
不包含头文件你这程序能编译过吗?
还有,aFont这个定义你看你写对了?
自定义函数不在 Main函数之前声明为什么能在main里调用?
作者: 龚芳平    时间: 2022-2-15 21:24
13205495918 发表于 2022-2-15 08:55
uchar这个一般情况下是说的unsigned char的缩写,这个需要你自己定义,一般是宏定义#define uchar unsigned ...

还是有错
下面显示的是
compiling main.c...
main.c(9): error C129: missing ';' before 'code'
main.c - 1 Error(s), 0 Warning(s).

作者: TEC    时间: 2022-2-15 21:32
龚芳平 发表于 2022-2-15 21:24
还是有错
下面显示的是
compiling main.c...

uint一样也要定义,耐心找些案例看看,先易后难。
作者: rundstedt    时间: 2022-2-15 23:41
13205495918 发表于 2022-2-15 08:55
uchar这个一般情况下是说的unsigned char的缩写,这个需要你自己定义,一般是宏定义#define uchar unsigned ...

我总觉得#define没有typedef合理。
作者: 188610329    时间: 2022-2-16 01:28
发表于 2022-2-15 23:41
我总觉得#define没有typedef合理。

#define 可以被反复包含,所以喜欢搬运代码, 又不太喜欢整理的  喜欢用 define
喜欢自己码代码的 会喜欢用 typedef
作者: AUG    时间: 2022-2-16 09:31
知其然不知其所以然,抄代码要你也要知道代码是干啥用,别C都不懂,然后就直接抄过来用。
作者: 龚芳平    时间: 2022-2-16 20:28
AUG 发表于 2022-2-16 09:31
知其然不知其所以然,抄代码要你也要知道代码是干啥用,别C都不懂,然后就直接抄过来用。

正在学习期间,还有很多需要请教





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