Я хочу добавить длину (целое число) строкового сообщения в другую строку, используя sprintf. Но каждый раз я получаю вышеуказанную ошибку.
void ClientToServer(const char *client_msg)
{
char str_len[20];
int len = strlen(client_msg);
char *ptr;
sprintf(ptr,"AT+CIPSEND=0,%d",len);
}
Полная ошибка:
CLEAN SUCCESSFUL (total time: 77ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi'
make -f nbproject/Makefile-default.mk dist/default/production/TokenOverWiFi.production.hex
make[2]: Entering directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi'
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -c -fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/TokMain.p1 TokMain.c
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -c -fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/TokenTimer.p1 TokenTimer.c
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -c -fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/TokenWifi.p1 TokenWifi.c
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -c -fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/WifiCom.p1 WifiCom.c
WifiCom.c:24:1: warning: (361) function declared implicit int
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -Wl,-Map=dist/default/production/TokenOverWiFi.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/TokenOverWiFi.production.elf build/default/production/TokMain.p1 build/default/production/TokenTimer.p1 build/default/production/TokenWifi.p1 build/default/production/WifiCom.p1
C:\Program Files (x86)\Microchip\xc8\v2.10\pic\sources\c90\common\sprintf.c:13:: error: (1098) conflicting declarations for variable "_sprintf" (WifiCom.c:24)
(908) exit status = 1
make[2]: *** [dist/default/production/TokenOverWiFi.production.hex] Error 1
nbproject/Makefile-default.mk:186: recipe for target 'dist/default/production/TokenOverWiFi.production.hex' failed
make[2]: Leaving directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 7s)
Редактировать: Предупреждения
Ошибка исчезла с парой предупреждений, когдадобавил stdio.h в начало всего заголовочного файла.
CLEAN SUCCESSFUL (total time: 49ms) make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf make[1]: Entering directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi' make -f nbproject/Makefile-default.mk dist/default/production/TokenOverWiFi.production.hex make[2]: Entering directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi' "C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe"
-mcpu=18F25K80 -c -fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/TokMain.p1 TokMain.c "C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -c
-fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/TokenTimer.p1 TokenTimer.c "C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -c
-fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/TokenWifi.p1 TokenWifi.c "C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80 -c
-fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/WifiCom.p1 WifiCom.c "C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe" -mcpu=18F25K80
-Wl,-Map=dist/default/production/TokenOverWiFi.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -fshort-double -fshort-float -memi=wordwrite -O1 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c90 -gdwarf-3 -mstack=compiled:auto:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/TokenOverWiFi.production.elf build/default/production/TokMain.p1 build/default/production/TokenTimer.p1 build/default/production/TokenWifi.p1 build/default/production/WifiCom.p1 WifiCom.c:25:: warning: (1257) local variable "_ptr" is used but never given a value C:\Program Files (x86)\Microchip\xc8\v2.10\pic\sources\c90\common\doprnt.c:558:: warning: (1498) pointer (sprintf@sp) in expression may have no targets C:\Program Files (x86)\Microchip\xc8\v2.10\pic\sources\c90\common\doprnt.c:1465:: warning: (1498) pointer (sprintf@sp) in expression may have no targets C:\Program Files (x86)\Microchip\xc8\v2.10\pic\sources\c90\common\doprnt.c:1550:: warning: (1498) pointer (sprintf@sp) in expression may have no targets C:\Program Files (x86)\Microchip\xc8\v2.10\pic\sources\c90\common\doprnt.c:1564:: warning: (1498) pointer (sprintf@sp) in expression may have no targets ::: warning: (1311) missing configuration setting for config word 0x300003; using default
Memory Summary:
Program space used 89Ah ( 2202) of 8000h bytes ( 6.7%)
Data space used 229h ( 553) of E41h bytes ( 15.2%)
Configuration bits used 7h ( 7) of 7h words (100.0%)
EEPROM space used 0h ( 0) of 400h bytes ( 0.0%)
ID Location space used 8h ( 8) of 8h bytes (100.0%)
Data stack space used 0h ( 0) of B41h bytes ( 0.0%)
make[2]: Leaving directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi' make[1]: Leaving directory 'C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi'
BUILD SUCCESSFUL (total time: 9s) Loading code from C:/Users/acer kuttan/Documents/pk/pk/TokenOverWiFi/dist/default/production/TokenOverWiFi.production.hex... Loading completed