Hi all!

I had some issues with the *_EPSILON constants on building a project
(actually I remember this issue so I think I had it on other projects, but
back then I think I just fixed in the project code with some #ifndef
#define instead of properly fixing the source of the bug in Mingw-w64;
fixing my own past mistake!).

According to Microsoft docs (
https://docs.microsoft.com/en-us/cpp/c-runtime-library/data-type-constants?view=vs-2019)
these should be defined in float.h. I can see that Mingw-w64 version of
this header defines a whole bunch of other macros of the same family, but
not these ones. So I added the #define-s next to the others using the same
coding style.

Attached is the patch for review and hopefully soon pushed on the
repository! :-)
Thanks.

Jehan

-- 
ZeMarmot open animation film
http://film.zemarmot.net
Liberapay: https://liberapay.com/ZeMarmot/
Patreon: https://patreon.com/zemarmot
Tipeee: https://www.tipeee.com/zemarmot
From 688a9729429fdb9bbddbbbe90aabdb3baa7662a7 Mon Sep 17 00:00:00 2001
From: Jehan <[email protected]>
Date: Mon, 23 Mar 2020 22:37:20 +0100
Subject: [PATCH] headers: define various *_EPSILON in float.h.

According to Microsoft docs, these 3 EPSILON macros are supposed to be
defined in float.h but Mingw-W64 header does not do so, which breaks
code assuming these exist.
---
 mingw-w64-headers/crt/float.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mingw-w64-headers/crt/float.h b/mingw-w64-headers/crt/float.h
index 099e2cd5..665b5600 100644
--- a/mingw-w64-headers/crt/float.h
+++ b/mingw-w64-headers/crt/float.h
@@ -118,6 +118,13 @@
 	/* ??? This is supposed to change with calls to fesetround in <fenv.h>.  */
 	#undef FLT_ROUNDS
 	#define FLT_ROUNDS 1
+
+	#undef FLT_EPSILON
+	#undef DBL_EPSILON
+	#undef LDBL_EPSILON
+	#define FLT_EPSILON __FLT_EPSILON__
+	#define DBL_EPSILON __DBL_EPSILON__
+	#define LDBL_EPSILON __LDBL_EPSILON__
     
 	#define _FLOAT_H___
 #endif
-- 
2.24.1

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to