厦门浪子 发表于 2020-10-9 14:12:12

加入printf语句后出现如下错误.求助

加入printf语句后出现如下错误.求教如何解决


Error: L6406E: No space in execution regions with .ANY selector matching ddl.o(i.ddl_memclr)

代码里面已经重定位了。
//取消ARM的半主机工作模式
#pragma import(__use_no_semihosting)                           
struct __FILE {
    int handle;
};

FILE __stdout;         
_sys_exit(int x)
{
    x = x;
}

int fputc(int ch, FILE *f){      
    while((USART1->SR&0X40)==0);
    USART1->DR = (u8) ch;      
    return ch;
}

小歆-2051663 发表于 2020-10-9 15:08:59

正常应该用下面的代码实现printf函数功能的


#ifdef __GNUC_
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
        HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF);

        return ch;
}


页: [1]
查看完整版本: 加入printf语句后出现如下错误.求助