Skip to content

Commit

Permalink
Fix #1435 - print JSON number as signed
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Jul 4, 2023
1 parent cc10897 commit ff458b2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
# else
# define PRIu64 "llu"
# endif
# ifndef PRId64
# if sizeof(long) == 8

This comment has been minimized.

Copy link
@yumkam

yumkam Jan 12, 2024

This cannot work: preprocessor cannot calculate sizeof (the only reason you have not seen that error out is because c99 is everywhere and it mandates presence of <inttypes.h>).

# define PRId64 "ld"
# else
# define PRId64 "lld"
# endif
# endif
# endif
#endif

Expand Down Expand Up @@ -588,7 +595,7 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
}
else if(d == (double)item->valueint)
{
length = sprintf((char*)number_buffer, "%" PRIu64, item->valueint);
length = sprintf((char*)number_buffer, "%" PRId64, item->valueint);
}
else
{
Expand Down

0 comments on commit ff458b2

Please sign in to comment.