libs: workaround for Visual Studio(MSVC) Compiler Error C2124

D:\archer\code\nuttx\libs\libc\stdlib\lib_strtod.c: error C2124: divide or mod by zero

Windows MSVC restrictions, MSVC doesn't allow division through a
zero literal, but allows it through const variable set to zero

Reference:
https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2124?view=msvc-170

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-02-08 16:15:56 +08:00
committed by Xiang Xiao
parent 86aed87487
commit 634baa5a2f
2 changed files with 32 additions and 16 deletions
+11 -7
View File
@@ -74,15 +74,19 @@
/* General Constants ********************************************************/
#define INFINITY (1.0/0.0)
#define NAN (0.0/0.0)
#define HUGE_VAL INFINITY
#ifndef _HUGE_ENUF
# define _HUGE_ENUF (1e+300) /* _HUGE_ENUF*_HUGE_ENUF must overflow */
#endif
#define INFINITY_F (1.0F/0.0F)
#define NAN_F (0.0F/0.0F)
#define INFINITY ((double)(_HUGE_ENUF * _HUGE_ENUF))
#define NAN ((double)(INFINITY * 0.0F))
#define HUGE_VAL INFINITY
#define INFINITY_L (1.0L/0.0L)
#define NAN_L (0.0L/0.0L)
#define INFINITY_F ((float)INFINITY)
#define NAN_F ((float)(INFINITY * 0.0F))
#define INFINITY_L ((long double)INFINITY)
#define NAN_L ((long double)(INFINITY * 0.0F))
#define isnan(x) ((x) != (x))
#define isnanf(x) ((x) != (x))