iar for stm8 报错Error[Li005]: no definition for "assert_failed"解决方案

时间:2021-12-03 21:12:55
Building configuration: STM8S_DEMO - Debug 
Updating build tree... 
Linking 
Error[Li005]: no definition for "assert_failed" [referenced from E:\STM8s\STM8S_DEMO\Debug\Obj\stm8s_gpio.o] 
Error while running Linker 

Total number of errors: 1 

Total number of warnings: 0 


void assert_failed(u8* file, u32 line);这个函数只是在“stm8s_conf.h”这个文件里面声明,用来在返回值验证出错的时候调用,所以还需要在一个恰当的地方将这个函数实现。一般我是“main.c”


解决方案:

1.

void assert_failed(u8* file, u32 line)

  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* Infinite loop */
  while (1)
  {
  }
} 加上这个

2.在stm8s_conf.h 中注释 #define USE_FULL_ASSERT