mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Fix compiler error when it encountered 1.0/0.0. It does not want to deal
with division by 0. Tricked the compiler to use volatile local variable zero instead, so it does not know for sure whether or not it's going to be zero.
This commit is contained in:
parent
e6b352d126
commit
224c2a8485
3
test.c
3
test.c
@ -68,6 +68,7 @@ void create_objects()
|
||||
struct record fields[2]={
|
||||
{"zip",37.7668,-1.223959e+2,"","SAN FRANCISCO","CA","94107","US"},
|
||||
{"zip",37.371991,-1.22026e+2,"","SUNNYVALE","CA","94085","US"}};
|
||||
volatile double zero = 0.0;
|
||||
|
||||
/* Here we construct some JSON standards, from the JSON site. */
|
||||
|
||||
@ -132,7 +133,7 @@ void create_objects()
|
||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||
|
||||
root=cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(root,"number", 1.0/0.0);
|
||||
cJSON_AddNumberToObject(root,"number", 1.0/zero);
|
||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user