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:
Irwan Djajadi 2016-04-22 14:27:20 -05:00
parent e6b352d126
commit 224c2a8485

3
test.c
View File

@ -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);
}