build: add option --disable-werror to configuretags/json-c-0.14-20200419
@@ -165,8 +165,13 @@ AS_IF([test "x$enable_Bsymbolic" = "xcheck"], | |||||
AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions]) | AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions]) | ||||
AC_SUBST(JSON_BSYMBOLIC_LDFLAGS) | AC_SUBST(JSON_BSYMBOLIC_LDFLAGS) | ||||
AX_APPEND_COMPILE_FLAGS([-Wall -Werror -Wcast-qual -Wno-error=deprecated-declarations]) | |||||
AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-string -Wno-unused-parameter]) | |||||
AC_ARG_ENABLE([werror], | |||||
AS_HELP_STRING([--disable-werror], [avoid treating compiler warnings as fatal errors])) | |||||
AS_IF([test "x$enable_werror" != "xno"], [AX_APPEND_COMPILE_FLAGS([-Werror])]) | |||||
AX_APPEND_COMPILE_FLAGS([-Wall -Wcast-qual -Wno-error=deprecated-declarations]) | |||||
AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-strings -Wno-unused-parameter]) | |||||
AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE]) | AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE]) | ||||
AC_LANG_PUSH([C]) | AC_LANG_PUSH([C]) | ||||
@@ -186,7 +186,8 @@ int main(int argc, char **argv) | |||||
printf("\nTesting deep_copy with a custom serializer set\n"); | printf("\nTesting deep_copy with a custom serializer set\n"); | ||||
json_object *with_serializer = json_object_new_string("notemitted"); | json_object *with_serializer = json_object_new_string("notemitted"); | ||||
json_object_set_serializer(with_serializer, my_custom_serializer, "dummy userdata", NULL); | |||||
char udata[] = "dummy userdata"; | |||||
json_object_set_serializer(with_serializer, my_custom_serializer, udata, NULL); | |||||
json_object_object_add(src1, "with_serializer", with_serializer); | json_object_object_add(src1, "with_serializer", with_serializer); | ||||
dst1 = NULL; | dst1 = NULL; | ||||
/* With a custom serializer in use, a custom shallow_copy function must also be used */ | /* With a custom serializer in use, a custom shallow_copy function must also be used */ | ||||
@@ -11,16 +11,17 @@ | |||||
int main() | int main() | ||||
{ | { | ||||
struct json_object *obj = json_object_new_double(0.5); | struct json_object *obj = json_object_new_double(0.5); | ||||
char udata[] = "test"; | |||||
printf("Test default serializer:\n"); | printf("Test default serializer:\n"); | ||||
printf("obj.to_string(standard)=%s\n", json_object_to_json_string(obj)); | printf("obj.to_string(standard)=%s\n", json_object_to_json_string(obj)); | ||||
printf("Test default serializer with custom userdata:\n"); | printf("Test default serializer with custom userdata:\n"); | ||||
obj->_userdata = "test"; | |||||
obj->_userdata = udata; | |||||
printf("obj.to_string(userdata)=%s\n", json_object_to_json_string(obj)); | printf("obj.to_string(userdata)=%s\n", json_object_to_json_string(obj)); | ||||
printf("Test explicit serializer with custom userdata:\n"); | printf("Test explicit serializer with custom userdata:\n"); | ||||
json_object_set_serializer(obj, json_object_double_to_json_string, "test", NULL); | |||||
json_object_set_serializer(obj, json_object_double_to_json_string, udata, NULL); | |||||
printf("obj.to_string(custom)=%s\n", json_object_to_json_string(obj)); | printf("obj.to_string(custom)=%s\n", json_object_to_json_string(obj)); | ||||
printf("Test reset serializer:\n"); | printf("Test reset serializer:\n"); | ||||