本文总结了嵌入式开发中常见的编译警告和错误类型及其解决方法,涉及变量定义、函数声明、代码格式等多个方面。

USE_.\USER\stm32f10x.h(298): error: #67: expected a "}"_DRIVER

STM3210X_HD删除 替换 为USE_STDPERIPH_DRIVER  保存 2019 1 18

************************************************************************

keil解决\SYSTEM\sys\stm32f10x.h(298): error: #67: expected a "}"

一般情况下,这是宏定义的问题,检查C/C++选项卡,在C/C++选项卡里,把STM3210X_HD从prepocessor symbol define 里面删掉
对于stm32f103c8t6的prepocessor symbol define 为USE_STDPERIPH_DRIVER

编译警告部分包括:未使用变量警告(#550-D)、文件末尾缺少换行(#1-D)、不可达代码(#111-D)、变量未初始化使用(C3017W)、声明但未引用变量(#177-D)、非void函数缺少返回值(#940-D)以及函数参数声明过时(#1295-D)等警告。

编译错误部分包括:缺少分号(#65)、变量重复定义(L6200E)、函数声明不兼容(#159)、不可修改的左值(#137)、缺少右括号(#18)以及未识别标记(#7)等错误。其中特别指出头文件中函数声明遗漏分号可能导致大量连锁错误。

这些问题的解决方法包括:合理使用volatile关键字、规范代码格式、添加必要的变量初始化和函数声明、修正语法错误等。开发人员应当重视这些警告和错误提示,养成良好的编程习惯,以提高代码质量和可靠性。

LX51 LINKER/LOCATER V4.41 - SN: K1PMC-19D1AC

1.warning:  #550-D: variable "d" was set but never used
描述:变量'd'定义但从未使用,或者是,虽然这个变量你使用了,但编译器认为变量d所在的语句没有意义,编译器把它优化了.
解决:仔细衡量所定义的变量d是否有用,若是认定变量d所在语句有意义,那么尝试用volatile关键字修饰变量d,若是真的没有用,那么删除掉以释放可能的内存.

2.warning:  #1-D: last line of file ends without a newline
描述:文件最后一行不是新的一行.编译器要求程序文件的最后一行必须是空行,想了半天没想通为什么要这样.
解决:可以不理会.若是觉得出现警告不爽,那么在出现警告的文件的最后一行敲个回车,空出一行.

3. warning:  #111-D: statement is unreachable
描述:声明不可能到达.多出现在这种场合:

[objc] view plain copy

  1. int main(void)  
  2. {  
  3.       ...  
  4.       while(1)  //无限循环,这在不使用操作系统的程序中最常见  
  5.       {  
  6.             ...  
  7.       }  
  8.       return 0; //这句声明在正常情况下不可能执行到,编译器发出警告  
  9. }  

解决:不理会.

4. warning: C3017W: data may be used before being set
描述:变量'data'在使用前没有明确的赋值.如:

[objc] view plain copy

  1. uint8 i,data;            //定义变量i和data,二者都没有明确赋值  
  2. for ( i = 0; i < 8; i++) //变量'i'在语句中被赋值0  
  3. {  
  4.     if ( IO1PIN & SO_CC2420 )  
  5.         data |= 0x01;    //变量'data'在使用前没有明确赋值,编译器发出警告  
  6.     else  
  7.         data &= ~0x01;  
  8. }  

解决:应仔细衡量该变量的初始值是否为0,若是,可以不理会这个警告,因为MDK编译器在程序执行前,会将使用到的数据区初始化为0,但若是该变量的初始值不应该是0,忽略这个警告可能会引起致命错误.这个警告应引起足够重视.应养成变量赋初值的习惯,好在有编译器给把关.

5. warning:  #177-D: variable "temp" was declared but never referenced
描述:变量'temp'进行了声明但没有引用.多出现在声明了一个变量,但却没有使用它,它和warning:  #550-D: variable "temp" was set but never used不同之处在于temp从没有使用过.
解决:若是定义的变量确实没有用,删除掉;若是有用,则在程序中使用.
与该警告类似的还有 warning:  #177-D: function "MACProcessBeacon" was declared but never referenced

6. warning:  #940-D: missing return statement at end of non-void function "DealwithInspect2"
描述:返回非空的函数"DealwithInspect2"的最后缺少返回值声明.如:

[objc] view plain copy

  1. int DealwithInspect2(uint32 test)  
  2. {  
  3.      ...  
  4.      ...  
  5.      ...  
  6.     //此处应该是return x;返回一个int型数据,若是没有返回值,编译器产生警告  
  7. }  

7..warning:  #1295-D: Deprecated declaration lcd_init - give arg types

描述:在定义函数的时候,如果你写上函数参数,就会有这个警告,比如void timer_init(); 这里就没有形参,如果这样的话,编译器会给出警告.

1. error:  #65: expected a ";"
描述:缺少分号.大多是漏忘';'.
解决:双击错误行,在定位到错误点的附近找到没加';'号的语句,加上分号.并不一定在定位到的错误行才却分号,可能是这行的上一行,也可能是下一行.

2. error:  #65: expected a ";"和 error:  #20: identifier "xxxx" is undefined一块出现,而且后面的error: #20错误可能一大堆
描述:这个错误对于第一次遇上的人来说绝对是个噩梦,当错误出现,满怀希望的双击错误提示,来到错误行时却愕然发现,错误行绝对没有错,于是找找错误行的上一行,下一行,没有错误,再找上上行,下下行...让人无比郁闷的事情出现了:编译提示的所有错误行都不可能有错误出现.其实这最可能是你在.h文件声明外部变量或者函数时,没有在声明语句的最后加分号!如果你有很多模块,如main.c,lcd.c,key.c...有很多头文件,如lcd.h,key.h,若是在lcd.h文件声明函数时没有加分号,那么这种错误可能定为到main.c中,所以要检查所有头文件.
解决:仔细检查.h文件,将分号补上.

3.  Error: L6200E: Symbol flagu multiply defined (by uart0.o and main.o).

描述:变量(也是一种符号)flagu多处定义(在uart0.c中和main.c都定义了).通常错在全局变量定义重复.比如:在main.c中定义全局变量flagu:

      uint8 flagu=0;

在uart0.c中也用到该变量,于是声明此变量,我通常都是先复制定义的变量再在变量前面加关键字extern修饰:

      extern uint8 flagu=0;

然后编译,就会出现上面的连接错误,原因在于,我在uart0.c中是又定义了一个变量,而不是声明变量,因为我给变量赋了初值"flagu=0",这样就重复定义了变量flag.正确的声明方法是去掉赋值部分:

      extern uint8 flagu;

解决办法:找到重复定义的变量,看情况修改一处.

4.error:  #159: declaration is incompatible with previous "wr_lcd" (declared at line 40)
描述:在wr_lcd函数还没有声明之前就已经使用了.多出现在两种情况:第一种,wr_lcd函数体还没有写,就已经用到了它,这种情况多出现在写一个程序的大体结构中,只是简单写一下框架.第二种情况比较常见,函数a调用函数b,但函数b的函数体在函数a的下面:

[objc] view plain copy

  1. void a(void) //函数a的实体  
  2. {  
  3.      b(); //调用函数b  
  4. }  
  5. void b(void) //函数b的实体  
  6. {  
  7.      ...  
  8. }  

这样如果点编译,就会产生error:  #159的错误,因为当函数a调用函数b时,发现在这之前都没有函数b的任何声明.
解决方法:在函数a调用函数b之前,对函数b进行声明,如:

[objc] view plain copy

  1. void b(void); //对函数b进行声明  
  2. void a(void) //函数a的实体  
  3. {  
  4.      b(); //调用函数b  
  5. }  
  6. void b(void) //函数b的实体  
  7. {  
  8.      ...  
  9. }  

 5. error:  #137: expression must be a modifiable lvalue

描述:表达式必须是一个可以修改的左值.主要出现在这种现象:

                 a=NUM;

NUM是一个数值或表达式,a为一个变量,但a被定义为像const这种不可更改的类型,导致NUM不能赋值给变量a.

解决方法:要么放弃赋值,要么修改变量属性.

6.error:  #18: expected a ")"
如果是出现在c文件中, 多半是因为少了一个")",或者错误行有编译器不识别的字符

如果出现在头文件中,错误行又是一个函数声明,多半是因为在函数声明中有编译器不认识的字符.

7.error:  #7: unrecognized token

未识别的标记,多半是切换成了中文标点。

Keil开发STM32更换MCU造成的编译不通过解决办法

 
1.更换MCU型号(我从STM32F103ZET6换成C8T6)
改选STM32F103C8
出现的编译错误:
*** Using Compiler 'V5.06 update 3 (build 300)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'USART1(interrupt)'
compiling stm32f10x_it.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\stm32f10x_it.c: 1 warning, 1 error
compiling main.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\main.c: 1 warning, 1 error
compiling init.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\init.c: 1 warning, 1 error
compiling kalman.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\kalman\kalman.c: 1 warning, 1 error
compiling scheduler.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\scheduler.c: 1 warning, 1 error
compiling mpu6050_measure.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\mpu6050_measure.c: 1 warning, 1 error
compiling bsp_usart1.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\usart\bsp_usart1.c: 1 warning, 1 error
compiling bsp_SysTick.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\SysTick\bsp_SysTick.c: 1 warning, 1 error
compiling attitude computation.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\attitude computation.c: 1 warning, 1 error
compiling bsp_i2c.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\i2c\bsp_i2c.c: 1 warning, 1 error
compiling bsp_mpu6050.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\mpu6050\bsp_mpu6050.c: 1 warning, 1 error
compiling bsp_encoder.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\encoder\bsp_encoder.c: 1 warning, 1 error
assembling startup_stm32f10x_hd.s...
compiling core_cm3.c...
compiling system_stm32f10x.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\CMSIS\system_stm32f10x.c: 1 warning, 1 error
compiling misc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\misc.c: 1 warning, 1 error
compiling stm32f10x_adc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_adc.c: 1 warning, 1 error
compiling stm32f10x_bkp.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_bkp.c: 1 warning, 1 error
compiling stm32f10x_can.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_can.c: 1 warning, 1 error
compiling stm32f10x_cec.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_cec.c: 1 warning, 1 error
compiling stm32f10x_crc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_crc.c: 1 warning, 1 error
compiling stm32f10x_dac.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_dac.c: 1 warning, 1 error
compiling stm32f10x_dbgmcu.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_dbgmcu.c: 1 warning, 1 error
compiling stm32f10x_dma.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_dma.c: 1 warning, 1 error
compiling stm32f10x_exti.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_exti.c: 1 warning, 1 error
compiling stm32f10x_flash.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_flash.c: 1 warning, 1 error
compiling stm32f10x_fsmc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_fsmc.c: 1 warning, 1 error
compiling stm32f10x_gpio.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_gpio.c: 1 warning, 1 error
compiling stm32f10x_i2c.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_i2c.c: 1 warning, 1 error
compiling stm32f10x_iwdg.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_iwdg.c: 1 warning, 1 error
compiling stm32f10x_pwr.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_pwr.c: 1 warning, 1 error
compiling stm32f10x_rcc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_rcc.c: 1 warning, 1 error
compiling stm32f10x_rtc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_rtc.c: 1 warning, 1 error
compiling stm32f10x_sdio.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_sdio.c: 1 warning, 1 error
compiling stm32f10x_spi.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_spi.c: 1 warning, 1 error
compiling stm32f10x_tim.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_tim.c: 1 warning, 1 error
compiling stm32f10x_usart.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_usart.c: 1 warning, 1 error
compiling stm32f10x_wwdg.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_wwdg.c: 1 warning, 1 error
"..\..\Output\Template.axf" - 36 Error(s), 36 Warning(s).
Target not created.
Build Time Elapsed:  00:00:11
这个问题是因为对应处理器内部资源少于启动文件中提及的内部资源,启动文件中某一部分寄存器地址在F103C8中没有,才会编译出错。
2.更换启动文件宏定义
由于STM32F103系列的不同型号MCU内部ROM和RAM不同,其地址区间也有些许差异
所以需要选择与型号对应的启动文件,并配置对应的宏定义
startup_stm32f10x_cl.s 互联型的器件,STM32F105xxSTM32F107xx
startup_stm32f10x_hd.s
 大容量的STM32F101xxSTM32F102xxSTM32F103xx
startup_stm32f10x_hd_vl.s
 大容量的STM32F100xx
startup_stm32f10x_ld.s
 小容量的STM32F101xxSTM32F102xxSTM32F103xx
startup_stm32f10x_ld_vl.s
 小容量的STM32F100xx
startup_stm32f10x_md.s
 中容量的STM32F101xxSTM32F102xxSTM32F103xx
startup_stm32f10x_md_vl.s
 中容量的STM32F100xx
startup_stm32f10x_xl.s FLASH
512K1024K字节的STM32F101xxSTM32F102xxSTM32F103xx
cl
:互联型产品,stm32f105/107系列
vl:超值型产品,stm32f100系列
xl:超高密度产品,stm32f101/103系列
ld:低密度产品,FLASH小于64K
md
:中等密度产品,FLASH=64 or 128
hd:高密度产品,FLASH大于128
ZET6的启动文件配置:
把STM32F10X_HD换成STM32F10X_MD
编译结果(能够通过):
做到这一步应该就可以用了,但是我还没有检查具体的内存地址空间,可以找个最小系统板下载一下就知道能不能用了。
现在存在的问题是启动文件用的还是HD版本的,能够编译MD通过但是还是想换成MD。
3.更换启动文件
更换前:
更换过程:
添加新的md文件,然后把hd文件删除
编译后能够通过。
4.可能出现的问题
error: L6235E: More than one section matches selector - cannot all be FIRST/LAST.
网上的解决方案:

编译环境:RVMDK

CPU :STM32F103VC

错误:.\obj\movSERVO.sct(7): error: L6235E: More than one section matches selector - cannot all be FIRST/LAST.

原因:项目中同时包含以下启动文件,

   startup_stm32f10x_hd.s

        startup_stm32f10x_md.s

        startup_stm32f10x_ld.s

     ......

        应该针对不同的CPU选择不同的启动文件。

解决办法1:从项目中删除不相关的启动文件

解决办法2:右击不相关的启动文件,点击 options for file 'startup_stm32f10x_md.s'...

                在弹出的对话框中的properties页,勾去灰化的'Include in Target Build'和‘Always Build’两项。
这个博客已经说明了问题的原因,但是导致问题的原因在Keil本身。
keil的这个地方有时候会出现一个选项,下方这个截图里没有出现。我在用Keil 5.14时会出现,刚才升级到5.21a后就没有再次出现。
那个选项里面会出现不少启动文件和相关文件,这些文件也自动加入编译,导致了有多个启动文件造成冲突,
解决方案:
右键,点击第一行
把Use for all project targets前面的勾选取消,点击ok
再编译就没有这个冲突了。

更多推荐