初中生
最后登录1970-1-1
在线时间 小时
注册时间2016-8-22
|
用MDK5编译程序的时候出现编译时 _stdout 在stdio_streams.o and usart.o中重复定义
//加入以下代码,支持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后,进行编译,会弹出如下错误:
..\OBJ\PICTURE.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.
"..\OBJ\PICTURE.axf" - 1 Error(s), 0 Warning(s).
如果我注释掉 FILE __stdout 这一行则会报出其他的错误:
linking...
..\OBJ\PICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _sys_open was referenced
..\OBJ\PICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _ttywrch was referenced
Finished: 0 information, 0 warning and 2 error messages.
"..\OBJ\PICTURE.axf" - 2 Error(s), 0 Warning(s).
请各位前辈给我解惑,QQ 1278219774 邮箱1278219774@qq.com
|
|