Discuz! Board

标题: 点亮LED灯编译不通过 [打印本页]

作者: 照月cool    时间: 2022-2-15 23:10
标题: 点亮LED灯编译不通过
照视频,把下载的示例复制过来后,在keil5中,编译失败。新手刚上手,发贴请教各位大佬。
编译错误内容如下:
  1. *** Using Compiler 'V5.06 update 1 (build 61)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
  2. Rebuild target 'Target 1'
  3. compiling main.c...
  4. ..\..\integration\nrfx\nrfx_glue.h(104): warning:  #260-D: explicit type is missing ("int" assumed)
  5.   static inline void _NRFX_IRQ_PRIORITY_SET(IRQn_Type irq_number,
  6. ..\..\integration\nrfx\nrfx_glue.h(104): error:  #65: expected a ";"
  7.   static inline void _NRFX_IRQ_PRIORITY_SET(IRQn_Type irq_number,
  8. ..\..\modules\nrfx\soc/nrfx_coredep.h(161): error:  #268: declaration may not appear after executable statement in block
  9.       
  10. _ALIGN(16)
  11. ..\..\modules\nrfx\soc/nrfx_coredep.h(168): error:  #268: declaration may not appear after executable statement in block
  12.       typedef void (* delay_func_t)(uint32_t);
  13. ..\..\modules\nrfx\soc/nrfx_coredep.h(169): error:  #268: declaration may not appear after executable statement in block
  14.       const delay_func_t delay_cycles =
  15. ..\..\modules\nrfx\soc/nrfx_coredep.h(172): error:  #268: declaration may not appear after executable statement in block
  16.       uint32_t cycles = time_us * NRFX_DELAY_CPU_FREQ_MHZ;
  17. ..\..\modules\nrfx\hal\nrf_gpio.h(797): error:  #268: declaration may not appear after executable statement in block
  18.       uint32_t i;
  19. ..\..\drive\led.h(28): warning:  #1-D: last line of file ends without a newline
  20.   #endif /* __LED_H */
  21. ..\main.c(44): warning:  #1-D: last line of file ends without a newline
  22.   }
  23. ..\main.c: 3 warnings, 6 errors
  24. compiling led.c...
  25. ..\..\integration\nrfx\nrfx_glue.h(104): warning:  #260-D: explicit type is missing ("int" assumed)
  26.   static inline void _NRFX_IRQ_PRIORITY_SET(IRQn_Type irq_number,
  27. ..\..\integration\nrfx\nrfx_glue.h(104): error:  #65: expected a ";"
  28.   static inline void _NRFX_IRQ_PRIORITY_SET(IRQn_Type irq_number,
  29. ..\..\modules\nrfx\soc/nrfx_coredep.h(161): error:  #268: declaration may not appear after executable statement in block
  30.       
  31. _ALIGN(16)
  32. ..\..\modules\nrfx\soc/nrfx_coredep.h(168): error:  #268: declaration may not appear after executable statement in block
  33.       typedef void (* delay_func_t)(uint32_t);
  34. ..\..\modules\nrfx\soc/nrfx_coredep.h(169): error:  #268: declaration may not appear after executable statement in block
  35.       const delay_func_t delay_cycles =
  36. ..\..\modules\nrfx\soc/nrfx_coredep.h(172): error:  #268: declaration may not appear after executable statement in block
  37.       uint32_t cycles = time_us * NRFX_DELAY_CPU_FREQ_MHZ;
  38. ..\..\modules\nrfx\hal\nrf_gpio.h(797): error:  #268: declaration may not appear after executable statement in block
  39.       uint32_t i;
  40. ..\..\drive\led.h(28): warning:  #1-D: last line of file ends without a newline
  41.   #endif /* __LED_H */
  42. ..\..\drive\led.c: 2 warnings, 6 errors
  43. assembling arm_startup_nrf52.s...
  44. compiling system_nrf52.c...
  45. ".\Objects\LED.axf" - 12 Error(s), 5 Warning(s).
  46. Target not created.
  47. Build Time Elapsed:  00:00:03
复制代码

作者: 照月cool    时间: 2022-2-15 23:14
使用的是 nRF5SDK1702d674dde 的SDK,nRF52832
作者: 照月cool    时间: 2022-2-17 22:59
最终还是自己解决了,解决方法是:在项目的Options中的c/c++选项卡中勾选 C99Mode




欢迎光临 Discuz! Board (http://qfv8.com/) Powered by Discuz! X3