libs: fix visual studio Compiler Error C2124
D:\code\incubator-nuttx\libs\libc\stdlib\lib_strtof.c(76,1): error C2124: divide or mod by zero
Windows MSVC restrictions, MSVC doesn't allow division through a
zero literal, but allows it through non-const variable set to zero
Reference:
static inline int is_real(float x)
{
- const float infinite = 1.0F / 0.0F;
+ /* NOTE: Windows MSVC restrictions, MSVC doesn't allow division through a
+ * zero literal, but allows it through non-const variable set to zero
+ */
+
+ float divzero = 0.0F;
+ const float infinite = 1.0F / divzero;
return (x < infinite) && (x >= -infinite);
}
@@ -99,7 +104,13 @@ float strtof(FAR const char *str, FAR char **endptr)
int n;
int num_digits;
int num_decimals;
- const float infinite = 1.0F / 0.0F;
+
+ /* NOTE: Windows MSVC restrictions, MSVC doesn't allow division through a
+ * zero literal, but allows it through non-const variable set to zero
+ */
+
+ float divzero = 0.0F;
+ const float infinite = 1.0F / divzero;
/* Skip leading whitespace */
