报错记录总结
[top]
一. 编译时错误
1.user\led.c(6): error: #144: a value of type "unsigned char" cannot be used to initialize an entity of type "GPIO_InitTypeDef" : xx类型不能初始化xx结构体类型
这个是由于初始化结构体是将{}写成();
2.Assignment to cast is illegal, lvalue casts are not supported
这个是因为使用宏定义#define x (type)(num). 然后在使用x->y时候, (type)(num)->y = 0x1234; 这样强制类型转换就在等号左边发生, 是不对的.应该改成#define x ((type*)num)
二. 运行时错误
三. 不报错效果与预期不符
1.在设计呼吸灯时, 出现灯常量逻辑之前验证过是正确的, 只是将函数移植到其他文件下面, 再运行就发现下载进单片机灯变成常量
这个是由于在main函数while循环中, 函数调用将 Led_Pattern_Breath(); 写成 void Led_Pattern_Breath();