怎么重定义实现printf打印log,目前使用Code Composer Studio Theia重定向
int fputc(int ch, FILE* stream)
{
if (ch == '\n') {
DL_UART_transmitData(UART_0_INST, '\r');
}
DL_UART_transmitData(UART_0_INST, ch);
return ch;
}
int fputs(const char* restrict s, FILE* restrict stream)
{
uint16_t i, len;
len = strlen(s);
for(i=0; i<len; i++)
{
DL_UART_transmitData(UART_0_INST, s[i]);
}
return len;
}
后,使用printf("\r\n")就会报错[8]"C:/ti/ccstheia131/ccs/tools/compiler/ti-cgt-armllvm_3.2.1.LTS/bin/tiarmclang.exe" @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O2 -gdwarf-3 -Wl,-m"empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.map" -Wl,--heap_size=0x800 -Wl,--stack_size=160 -Wl,-i"C:/ti/mspm0_sdk_2_01_00_03/source" -Wl,-i"C:/Users/zhihao.she/workspace_ccstheia/empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang" -Wl,-i"C:/Users/zhihao.she/workspace_ccstheia/empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang/Debug/syscfg" -Wl,-i"C:/ti/ccstheia131/ccs/tools/compiler/ti-cgt-armllvm_3.2.1.LTS/lib" -Wl,--diag_wrap=off -Wl,--display_error_number -Wl,--warn_sections -Wl,--xml_link_info="empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang_linkInfo.xml" -Wl,--rom_model -o "empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.out" "./empty.o" "./ti_msp_dl_config.o" "./startup_mspm0g350x_ticlang.o" "./ti/driverlib/dl_adc12.o" "./ti/driverlib/dl_aes.o" "./ti/driverlib/dl_aesadv.o" "./ti/driverlib/dl_common.o" "./ti/driverlib/dl_crc.o" "./ti/driverlib/dl_crcp.o" "./ti/driverlib/dl_dac12.o" "./ti/driverlib/dl_dma.o" "./ti/driverlib/dl_flashctl.o" "./ti/driverlib/dl_i2c.o" "./ti/driverlib/dl_keystorectl.o" "./ti/driverlib/dl_lcd.o" "./ti/driverlib/dl_lfss.o" "./ti/driverlib/dl_mathacl.o" "./ti/driverlib/dl_mcan.o" "./ti/driverlib/dl_opa.o" "./ti/driverlib/dl_rtc_common.o" "./ti/driverlib/dl_spi.o" "./ti/driverlib/dl_timer.o" "./ti/driverlib/dl_trng.o" "./ti/driverlib/dl_uart.o" "./ti/driverlib/dl_vref.o" "./ti/driverlib/m0p/dl_interrupt.o" "./ti/driverlib/m0p/sysctl/dl_sysctl_mspm0c110x.o" "./ti/driverlib/m0p/sysctl/dl_sysctl_mspm0g1x0x_g3x0x.o" "./ti/driverlib/m0p/sysctl/dl_sysctl_mspm0l11xx_l13xx.o" "./ti/driverlib/m0p/sysctl/dl_sysctl_mspm0l122x_l222x.o" "./tym_module/tym_log.o" "./tym_module/tym_main.o" -Wl,-l"./device_linker.cmd" -Wl,-ldevice.cmd.genlibs -Wl,-llibc.a
[9]makefile:174: recipe for target 'empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.out' failed
[10]error #10056: symbol "fputs" redefined: first defined in "./empty.o"; redefined in "C:\ti\ccstheia131\ccs\tools\compiler\ti-cgt-armllvm_3.2.1.LTS\lib\armv6m-ti-none-eabi/c/libc.a<fputs.c.obj>"
[11]error #10010: errors encountered during linking; "empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.out" not built
[12]tiarmclang: error: tiarmlnk command failed with exit code 1 (use -v to see invocation)
[13]gmake[1]: *** [empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.out] Error 1
[14]makefile:170: recipe for target 'all' failed
[15]gmake: *** [all] Error 2
[16]**** Build Finished
[9]makefile:174: recipe for target 'empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.out' failed
[10]error #10056: symbol "fputs" redefined: first defined in "./empty.o"; redefined in "C:\ti\ccstheia131\ccs\tools\compiler\ti-cgt-armllvm_3.2.1.LTS\lib\armv6m-ti-none-eabi/c/libc.a<fputs.c.obj>"
[11]error #10010: errors encountered during linking; "empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.out" not built
[12]tiarmclang: error: tiarmlnk command failed with exit code 1 (use -v to see invocation)
[13]gmake[1]: *** [empty_driverlib_src_LP_MSPM0G3507_nortos_ticlang.out] Error 1
[14]makefile:170: recipe for target 'all' failed
[15]gmake: *** [all] Error 2
[16]**** Build Finished
但是不使用printf("\r\n")则不会编译报错,这个问题需要怎么解决