Keil编译常见问题

来源:互联网 发布:gopro studio for mac 编辑:程序博客网 时间:2024/04/28 01:48

1.led的前后今生

1.出现warning:  #1-D: last line of file ends without a newline

解决方案:这是由于在函数的“}”之后没有回车的原因造成的,添加回车后,可消除警告。

2.出现main.c: Error: command-line:  #992: invalid macro definition: USE_STDPERIPH_DRIVER.STM32F10X_HD

解决方案:这是由于中间的逗号写错了,应该是英文的逗号。

3.出现main.c(2): warning:  #9-D: nested comment is not allowed

解决方案:这是注释嵌套的结果,不是程序本身的问题,对程序运行没有任何影响。

/*/**/去掉第二个/*可以消除警告

4.出现LED\led.c(33): error:  #20: identifier "GPIO_InitStructure" is undefined

解决方案:这是由于变量没有定义造成的,检查定义的变量是否写错,注意大小写GPIO_Initstructure。

5.出现main.c(21): warning:  #223-D: function "LED_GPIO_Config" declared implicitly

解决方案:是由于led.c中定义了一个函数,led.h中没有申明这个函数,只需要在led.h中申明了即可解决

2.SysTick

1.出现Delay\Delayus.c(14): error:  #20: identifier "TimingDelay" is undefined

解决方案;是由于delayus()中没有定义造成,定义静态变量static __IO u32 TimingDelay;即可解决

2.出现stm32f10x_it.c(143): warning:  #223-D: function "TimingDelay_Decrement" declared implicitly

解决方案:在stm32f10x_it.c文件中,外部声明extern void TimingDelay_Decrement(void);

3.KEY_POLLING

1.出现error:  #20: identifier "GPIO" is undefined?

解决方案:将GPIO InitTypeDef GPIO InitStructure;改成GPIO_InitTypeDef GPIO_InitStructure;

4.USART1

1.出现warning:  #177-D: variable "GPIO_InitSuructure" was declared but never referenced

解决方案:常常是函数书写错误,改成GPIO_InitStructure

2.error:  #20: identifier "USARTx" is undefined

解决方案:由于USARTx没有定义造成,首先检查第一次出现USART的位置.void USART1_printf(USART TypeDef* USARTx, uint8_t *Data,...)在定义结构体出错,改为void USART1_printf(USART_TypeDef* USARTx, uint8_t *Data,...)

3.出现usart1\usart1.c(129): error:  #20: identifier "va_list" is undefined

解决方案:va函数在头文件stdarg.h中,要使用其中的参数,必须包含此头文件#include "stdarg.h"

4.出现usart1\usart1.c(47): error:  #20: identifier "FILE" is undefined

解决方案;这是由于使用了重定向C函数,又没有包含该函数的头文件#include “stdio.h”,在usart.h中添加即可解决问题,还要在编译器中设置一个选项 Use MicroLIB (使用微库)。

0 0