Skip to content

Commit

Permalink
Merge pull request #491 from ploxiln/disable_werror
Browse files Browse the repository at this point in the history
build: add option --disable-werror to configure
  • Loading branch information
hawicz committed Jun 9, 2019
2 parents 2b1903c + 634900d commit 07ea04e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions configure.ac
Expand Up @@ -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])
Expand Down
3 changes: 2 additions & 1 deletion tests/test_deep_copy.c
Expand Up @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions tests/test_double_serializer.c
Expand Up @@ -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");
Expand Down

0 comments on commit 07ea04e

Please sign in to comment.