..\SYSTEM\delay\delay.h(20): error: #18: expected a “)“

本文讲述了在KEIL编译过程中遇到的错误,由于函数形参SYSCLK与系统宏名冲突导致。解决方法是修改形参名以避免识别混乱。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在KEIL中有时编译过程中会出现下面这样的错误。

 明明代码里面并没有缺少小括号,但是就是找不到错误。

 

 真正的原因是因为

在20行的地方形参 SYSCLK 与系统的中某个文件的宏名字相同导致这样的问题。

 解决方案:

把函数的形参随便修改下就OK了。

 

..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\STM32F10x_FWLib\src\stm32f10x_gpio.c: 1 warning, 1 error compiling stm32f10x_adc.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\STM32F10x_FWLib\src\stm32f10x_adc.c: 1 warning, 1 error compiling sys.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\SYSTEM\sys\sys.c: 1 warning, 1 error compiling key.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\HARDWARE\KEY\key.c: 1 warning, 1 error compiling stm32f10x_it.c... stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; stm32f10x_it.c: 1 warning, 1 error compiling delay.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\SYSTEM\delay\delay.c(134): error: #20: identifier "SystemCoreClock" is undefined fac_us=SystemCoreClock/8000000; //为系统时?拥?1/8 ..\SYSTEM\delay\delay.c: 1 warning, 2 errors compiling usart.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\SYSTEM\usart\usart.c: 1 warning, 1 error compiling led.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\HARDWARE\LED\led.c: 1 warning, 1 error compiling main.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; main.c: 1 warning, 1 error compiling lsens.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\HARDWARE\LSENS\lsens.c: 1 warning, 1 error compiling system_stm32f10x.c... stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; system_stm32f10x.c: 1 warning, 1 error compiling misc.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\STM32F10x_FWLib\src\misc.c: 1 warning, 1 error compiling adc.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\HARDWARE\ADC\adc.c: 1 warning, 1 error compiling stm32f10x_rcc.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\STM32F10x_FWLib\src\stm32f10x_rcc.c: 1 warning, 1 error compiling stm32f10x_usart.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\STM32F10x_FWLib\src\stm32f10x_usart.c: 1 warning, 1 error compiling stm32f10x_fsmc.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\STM32F10x_FWLib\src\stm32f10x_fsmc.c: 1 warning, 1 error compiling lcd.c... ..\USER\stm32f10x.h(298): error: #67: expected a "}" ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ ..\USER\stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error } IRQn_Type; ..\HARDWARE\LCD\lcd.c: 1 warning, 1 error compiling core_cm3.c... "..\OBJ\LSENS.axf" - 18 Error(s), 17 Warning(s). Target not created. Build Time Elapsed: 00:00:03
06-26
出现以下报错Rebuild started: Project: SmartCar *** Using Compiler &#39;V5.06 update 6 (build 750)&#39;, folder: &#39;D:\keil(C51+MDK)\KEIL_MDK\ARM\ARMCC\Bin&#39; Rebuild target &#39;SmartCar&#39; compiling main.c... User\main.c(58): warning: #223-D: function "sprintf" declared implicitly sprintf(modeMsg, "Mode: AVOID\r\n"); User\main.c(110): error: #65: expected a ";" { User\main.c(139): warning: #12-D: parsing restarts here after previous syntax error break; User\main.c(141): error: #121: a case label may only be used within a switch case 2: // 杞集 User\main.c(142): error: #20: identifier "last_action_time" is undefined if(Delay_GetDiffMS(last_action_time) >= 500) User\main.c(144): error: #20: identifier "avoid_state" is undefined avoid_state = 0; // 杩斿洖妫€娴嬬姸鎬? User\main.c(146): error: #116: a break statement may only be used within a loop or switch break; User\main.c(148): error: #169: expected a declaration } User\main.c(173): warning: #12-D: parsing restarts here after previous syntax error Gradual_Turn(SHARP_TURN_SPEED, -SHARP_TURN_SPEED); // 鎬ュ乏杞? User\main.c(174): error: #77-D: this declaration has no storage class or type specifier last_turn_time = Delay_GetTick(); User\main.c(174): error: #59: function call is not allowed in a constant expression last_turn_time = Delay_GetTick(); User\main.c(175): error: #77-D: this declaration has no storage class or type specifier turn_state = 1; User\main.c(176): error: #169: expected a declaration return; User\main.c(177): error: #169: expected a declaration } User\main.c(279): warning: #12-D: parsing restarts here after previous syntax error Delay_ms(5); User\main.c(280): error: #169: expected a declaration } User\main.c: 4 warnings, 12 errors compiling stm32f10x_dac.c... compiling stm32f10x_it.c... compiling stm32f10x_adc.c... compiling stm32f10x_crc.c... compiling stm32f10x_can.c... compiling stm32f10x_exti.c... compiling misc.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_cec.c... compiling stm32f10x_bkp.c... compiling stm32f10x_dma.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_gpio.c... compiling stm32f10x_flash.c... compiling stm32f10x_i2c.c... compiling stm32f10x_iwdg.c... compiling stm32f10x_pwr.c... compiling stm32f10x_rcc.c... compiling stm32f10x_rtc.c... compiling stm32f10x_sdio.c... compiling stm32f10x_spi.c... compiling stm32f10x_usart.c... compiling stm32f10x_tim.c... assembling startup_stm32f10x_md.s... compiling stm32f10x_wwdg.c... compiling system_stm32f10x.c... compiling bluetooth.c... compiling Delay.c... compiling pwm.c... compiling servo.c... compiling motor.c... compiling core_cm3.c... compiling pwm_motor.c... compiling ultrasound.c... compiling sys.c... compiling trace.c... ".\OBJ\project.axf" - 12 Error(s), 4 Warning(s). Target not created. Build Time Elapsed: 00:00:07
06-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值