Which header file includes asprintf function.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Which header file includes asprintf function.

436 Views
TiDiChi
Contributor I

Hi

I am developing a program with modbus tcp/ip server module. When i used a function "asprintf", console displayed:

"Building file: ../seslib/freemodbus/port/porttcp.c Invoking: MCU C Compiler arm-none-eabi-gcc -std=gnu99 -D__REDLIB__ -DCPU_MIMXRT1166DVM6A -DCPU_MIMXRT1166DVM6A_cm7 -D_POSIX_SOURCE -DXIP_BOOT_HEADER_DCD_ENABLE=1 -DUSE_SDRAM -DDATA_SECTION_IS_CACHEABLE=1 -DSDK_DEBUGCONSOLE=1 -DXIP_EXTERNAL_FLASH=1 -DXIP_BOOT_HEADER_ENABLE=1 -DLWIP_ENET_FLEXIBLE_CONFIGURATION -DFSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1 -DFSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE -DUSE_RTOS=1 -DPRINTF_ADVANCED_ENABLE=1 -DHTTPSRV_CFG_WEBSOCKET_ENABLED=1 -DFSL_SDK_DRIVER_QUICK_ACCESS_ENABLE=1 -DLWIP_DISABLE_PBUF_POOL_SIZE_SANITY_CHECKS=1 -DSERIAL_PORT_TYPE_UART=1 -DSDK_OS_FREE_RTOS -DMCUXPRESSO_SDK -DCR_INTEGER_PRINTF -DPRINTF_FLOAT_ENABLE=0 -D__MCUXPRESSO -D__USE_CMSIS -DDEBUG -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\component\phy" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\component\silicon_id" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\drivers" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\lwip\port" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\lwip\src" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\lwip\src\include" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\lwip\src\apps\httpsrv" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\lwip\src\include\lwip\apps" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\device" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\utilities" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\component\uart" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\component\serial_manager" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\component\lists" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\startup" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\xip" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\CMSIS" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\freertos\freertos-kernel\include" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\freertos\freertos-kernel\portable\GCC\ARM_CM4F" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\drivers\freertos" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\component\log" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\source" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\board" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\seslib\freemodbus\modbus\include" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\seslib\ses_timer" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\seslib\freemodbus\port" -I"E:\Embedded\NXP\Projects\MCU\test_lwip_httpsrv_freertos_cm7\seslib\freemodbus\modbus\tcp" -Og -fno-common -g3 -c -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -fmacro-prefix-map="../seslib/freemodbus/port/"= -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -D__REDLIB__ -fstack-usage -specs=redlib.specs -MMD -MP -MF"seslib/freemodbus/port/porttcp.d" -MT"seslib/freemodbus/port/porttcp.o" -MT"seslib/freemodbus/port/porttcp.d" -o "seslib/freemodbus/port/porttcp.o" "../seslib/freemodbus/port/porttcp.c" ../seslib/freemodbus/port/porttcp.c: In function 'vMBTCPPortBindAddr': ../seslib/freemodbus/port/porttcp.c:362:9: warning: implicit declaration of function 'asprintf'; did you mean '_sprintf'? [-Wimplicit-function-declaration] 362 | if (asprintf(&pcStr, "%u", xConfig.usPort) == -1) { | ^~~~~~~~ | _sprintf Finished building: ../seslib/freemodbus/port/porttcp.c"

Then i replaced "sprintf" but my program did not run false. I debuged but my program stopped ai "sprintf" function.

What need i do to fix this bug!

0 Kudos
2 Replies

396 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi @TiDiChi ,

 

asprintf() is part of the GNU and BSD extensions to libc , not sure if you are developing based on this, but for C environment. sprintf()is more popular . Please kindly refer to https://stackoverflow.com/questions/12746885/why-use-asprintf-instead-of-sprintf for more details.

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

391 Views
TiDiChi
Contributor I
Thank you very much @Kan_Li.
I found the method that used sprintf() function for my program.

Have a great day,
TiDiChi
0 Kudos