cjson ignore and comment
This commit is contained in:
parent
8661c89633
commit
e27ef8ca49
3 changed files with 20 additions and 6 deletions
1
cjson/.gitignore
vendored
Normal file
1
cjson/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
cjson*
|
||||||
|
|
@ -1,12 +1,22 @@
|
||||||
CC ?= gcc
|
CC ?= cc
|
||||||
CFLAGS ?= -Wall -O2 -lcjson
|
CFLAGS ?= -Wall -O2 -I.
|
||||||
|
LDFLAGS ?=
|
||||||
|
|
||||||
TARGET = main.elf
|
TARGET = main.elf
|
||||||
SRC = main.c
|
SRC = main.c ./cjson/cJSON.c
|
||||||
|
|
||||||
$(TARGET): $(SRC)
|
$(TARGET): $(SRC)
|
||||||
@echo CC $@
|
@echo CC $@
|
||||||
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
|
CJSON_URL = https://github.com/DaveGamble/cJSON/archive/refs/heads/master.tar.gz
|
||||||
|
CJSON_TAR = cjson.tar.gz
|
||||||
|
CJSON_DIR = cJSON-master
|
||||||
|
|
||||||
|
cjson:
|
||||||
|
curl -L $(CJSON_URL) -o $(CJSON_TAR)
|
||||||
|
tar -xzf $(CJSON_TAR)
|
||||||
|
mv ./cJSON-master ./cjson
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGET)
|
rm -f $(TARGET)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <cjson/cJSON.h>
|
#include "cjson/cJSON.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
char *build_set_level_command(int level) {
|
char *build_set_level_command(int level) {
|
||||||
cJSON *root = cJSON_CreateObject();
|
cJSON *root = cJSON_CreateObject();
|
||||||
|
|
@ -9,10 +10,12 @@ char *build_set_level_command(int level) {
|
||||||
// char *message = cJSON_PrintUnformatted(root);
|
// char *message = cJSON_PrintUnformatted(root);
|
||||||
char *msg2 = cJSON_Print(root);
|
char *msg2 = cJSON_Print(root);
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
return msg2; // Remember to free this when done!
|
return msg2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
printf("%s\n", build_set_level_command(10));
|
char *msg = build_set_level_command(10);
|
||||||
|
printf("%s\n", msg);
|
||||||
|
free(msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue