From 6d54ec2ff716818e3229fa63a55895a1b5833c96 Mon Sep 17 00:00:00 2001 From: jsalling Date: Sat, 27 Aug 2016 15:34:10 -0500 Subject: [PATCH] Get rid of conversion warning when using UNITY_FLOAT_VERBOSE with doubles Change the parameter of UnityPrintFloat from float to double (_UD) The call to snprintf uses implict default promotion to a double anyway --- src/unity.c | 2 +- src/unity_internals.h | 44 ++++++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/unity.c b/src/unity.c index 1195858..32c1880 100644 --- a/src/unity.c +++ b/src/unity.c @@ -257,7 +257,7 @@ void UnityPrintMask(const _U_UINT mask, const _U_UINT number) # endif #endif -void UnityPrintFloat(_UF number) +void UnityPrintFloat(_UD number) { char TempBuffer[UNITY_VERBOSE_NUMBER_MAX_LENGTH + 1]; snprintf(TempBuffer, sizeof(TempBuffer), "%.6f", number); diff --git a/src/unity_internals.h b/src/unity_internals.h index b2e296a..557b6a4 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -251,32 +251,38 @@ typedef UNITY_FLOAT_TYPE _UF; /* unlike FLOAT, we DON'T include by default */ #ifndef UNITY_EXCLUDE_DOUBLE -#ifndef UNITY_INCLUDE_DOUBLE -#define UNITY_EXCLUDE_DOUBLE -#endif + #ifndef UNITY_INCLUDE_DOUBLE + #define UNITY_EXCLUDE_DOUBLE + #endif #endif #ifdef UNITY_EXCLUDE_DOUBLE -/* No Floating Point Support */ -#undef UNITY_DOUBLE_PRECISION -#undef UNITY_DOUBLE_TYPE -#undef UNITY_DOUBLE_VERBOSE + /* No Floating Point Support */ + #undef UNITY_DOUBLE_PRECISION + #undef UNITY_DOUBLE_TYPE + #undef UNITY_DOUBLE_VERBOSE -#ifdef UNITY_INCLUDE_DOUBLE -#undef UNITY_INCLUDE_DOUBLE -#endif + #ifdef UNITY_INCLUDE_DOUBLE + #undef UNITY_INCLUDE_DOUBLE + #endif + + #ifdef UNITY_FLOAT_VERBOSE + typedef _UF _UD; + /* For parameter in UnityPrintFloat, double promotion required */ + #endif #else -/* Double Floating Point Support */ -#ifndef UNITY_DOUBLE_PRECISION -#define UNITY_DOUBLE_PRECISION (1e-12f) -#endif -#ifndef UNITY_DOUBLE_TYPE -#define UNITY_DOUBLE_TYPE double -#endif -typedef UNITY_DOUBLE_TYPE _UD; + /* Double Floating Point Support */ + #ifndef UNITY_DOUBLE_PRECISION + #define UNITY_DOUBLE_PRECISION (1e-12f) + #endif + + #ifndef UNITY_DOUBLE_TYPE + #define UNITY_DOUBLE_TYPE double + #endif + typedef UNITY_DOUBLE_TYPE _UD; #endif @@ -484,7 +490,7 @@ void UnityPrintNumberUnsigned(const _U_UINT number); void UnityPrintNumberHex(const _U_UINT number, const char nibbles); #ifdef UNITY_FLOAT_VERBOSE -void UnityPrintFloat(const _UF number); +void UnityPrintFloat(const _UD number); #endif /*-------------------------------------------------------