请教高手:
我用的MDK5.14,库函数版本3.5,探索者STM32F4开发板;
自己新建的工程,用原子哥的参考代码 SYSTEM 里面的usart.c,
//加入以下代码,支持printf函数,而不需要选择use MicroLIB
#if 1
#pragma import(__use_no_semihosting)
//标准库需要的支持函数
struct __FILE
{
int handle;
};
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x)
{
x = x;
}
//重定义fputc函数
int fputc(int ch, FILE *f)
{
while((USART1->SR&0X40)==0);//循环发送,直到发送完毕
USART1->DR = (u8) ch;
return ch;
}
在不勾选 use microlib后,进行编译,会弹出如下错误:
..OBJPICTURE.axf: Error: L6200E: Symbol __stdout multiply defined (by stdio_streams.o and usart.o).
Not enough information to list image symbols.
Not enough information to list the image map.
Finished: 2 information, 0 warning and 1 error messages.
"..OBJPICTURE.axf" - 1 Error(s), 0 Warning(s).
如果我注释掉 FILE __stdout 这一行则会报出其他的错误:
linking...
..OBJPICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _sys_open was referenced
..OBJPICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _ttywrch was referenced
Finished: 0 information, 0 warning and 2 error messages.
"..OBJPICTURE.axf" - 2 Error(s), 0 Warning(s).
奇怪的是,如果直接用原子哥的模板工程则不会报错。
刚才我又试过直接用原子哥的模板,不会报错,添加自己的car车牌识别程序上去就会报这样的错误 把car移除就不会报错!
是不是我的car程序有地方出错了?可是又没检查出来!
希望有解决的大神指教下小弟
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
不过没关系,我给你说怎么改,很简单.
首先,为了你的scanf,去定义FILE __stdin;在你的usart.c中
然后自己实现C库的文件系统函数,有以下几个:fopen,fclose,exit,fread,fwrite,fseek,fprintf,你自己的函数不能和C库函数重名.
我给你定义了宏,带替对应的C库函数,就可以编译通过了
#define my_fopen(a,b) 0
#define my_fclose(a) 0
#define my_exit(a) while(1)
#define my_fprintf(a,b,...) 0
#define my_fread(a,b,c,d) 0
#define my_fwrite(a,b,c,d) 0
#define my_fseek(a,b,c) 0
一周热门 更多>