STM32 HAL库程序编译错误解决方案指南
1、当出现下列错误时:
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(1): error: A1167E: Invalid line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(2): error: A1137E: Unexpected characters at end of line
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(3): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(4): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(5): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(6): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(7): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(8): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(9): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(10): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(11): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(12): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(13): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(14): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(15): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(16): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(17): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(18): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(19): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(20): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(21): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(22): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(23): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(24): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(25): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(26): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(27): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(28): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(29): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(30): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(31): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(32): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(33): error: A1137E: Unexpected characters at end of line
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(34): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(35): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(36): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(37): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(38): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(39): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(40): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(41): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(42): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(43): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(44): error: A1137E: Unexpected characters at end of line
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(45): error: A1137E: Unexpected characters at end of line
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(47): error: A1167E: Invalid line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(48): error: A1159E: Label missing from line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(49): error: A1137E: Unexpected characters at end of line
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(51): error: A1167E: Invalid line start
..\..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c(52): error: A1159E: Label missing from line start
一共50个错误的时候,我们点击每一项错误的时候,会发现其跳到“system_stm32f1xx.c”该文件中,基本点击哪个错误就显示错误就在哪一行,那也就是说该文件的开头就已经是错误了。而且该C程序并没有链接到其他文件:
仔细观察该文件:
会发现该文件第一行开始用的是C语言的注释,那就给了我们一个提示:软件应该是把该文件当成其他的文件了,并不是将其看成C程序去解释,所以我们右击该文件,得到下图:
点击Option for File 'system_stm32xx.c',得到如下图:
我们看到“File Type”文件类型为“Assembly language file”(汇编语言文件),显然系统把它当成汇编语言理解,所以我们需要把文件类型改成C语言类型,点击该倒三角,选择“C Source file”:
编译后就不会出现该问题了,“system_stm32f1xx.c”文件也被链接上了:
作者:m0_65297336