diff --git a/configure.ac b/configure.ac index 272ea6a..120797e 100644 --- a/configure.ac +++ b/configure.ac @@ -165,8 +165,13 @@ AS_IF([test "x$enable_Bsymbolic" = "xcheck"], AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions]) 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]) AC_LANG_PUSH([C]) diff --git a/tests/test_deep_copy.c b/tests/test_deep_copy.c index 7a6e63f..63f882b 100644 --- a/tests/test_deep_copy.c +++ b/tests/test_deep_copy.c @@ -186,7 +186,8 @@ int main(int argc, char **argv) printf("\nTesting deep_copy with a custom serializer set\n"); 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); dst1 = NULL; /* With a custom serializer in use, a custom shallow_copy function must also be used */ diff --git a/tests/test_double_serializer.c b/tests/test_double_serializer.c index 21612c8..bb1b8a2 100644 --- a/tests/test_double_serializer.c +++ b/tests/test_double_serializer.c @@ -11,16 +11,17 @@ int main() { struct json_object *obj = json_object_new_double(0.5); + char udata[] = "test"; printf("Test default serializer:\n"); printf("obj.to_string(standard)=%s\n", json_object_to_json_string(obj)); 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("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("Test reset serializer:\n");