From 3f349a425880131a09ab4839d36dc416291adedb Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Wed, 1 Mar 2017 08:58:11 +0100 Subject: [PATCH] Add -Wdouble-promotion compiler flag --- CMakeLists.txt | 1 + cJSON.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9a22ff..730ee1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,7 @@ if (ENABLE_CUSTOM_COMPILER_FLAGS) -Wc++-compat -fstack-protector-strong -Wcomma + -Wdouble-promotion ) endif() diff --git a/cJSON.c b/cJSON.c index 71dee8d..392da69 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1914,7 +1914,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) for(i = 0; a && (i < (size_t)count); i++) { - n = cJSON_CreateNumber(numbers[i]); + n = cJSON_CreateNumber((double)numbers[i]); if(!n) { cJSON_Delete(a);