[gfortran] Disable "long double" real kind on mingw32

FX Coudert fxcoudert@gmail.com
Mon Jan 22 21:14:00 GMT 2007


Hi all,

The Windows printf doesn't handle "long double" right, and since this  
all floating-point values are passed to the library as long double,  
gfortran is unusable on mingw32 if it thinks it has a long double  
type. For more than one year, I've been building my gfortran mingw32  
binaries with a hack in the front-end not to use them. I'd like to  
install that on mainline, by defining a GFORTRAN_WITHOUT_LONGDOUBLE  
macro in the mingw32 config file.

Do I need approval for the config/ part of the patch? (it defines a  
macro that only the Fortran front-end will use)

Otherwise, and unless someone objects to the following patch in the  
next few days, I'll commit it to mainline.

Thanks,
FX



Index: fortran/trans-types.c
===================================================================
--- fortran/trans-types.c       (revision 118930)
+++ fortran/trans-types.c       (working copy)
@@ -172,8 +172,10 @@
          library assumes these are the only floating point types.  */
        if (mode != TYPE_MODE (float_type_node)
-         && (mode != TYPE_MODE (double_type_node))
-          && (mode != TYPE_MODE (long_double_type_node)))
+#ifdef GFORTRAN_WITHOUT_LONGDOUBLE
+          && (mode != TYPE_MODE (long_double_type_node))
+#endif
+         && (mode != TYPE_MODE (double_type_node)))
         continue;
        /* Let the kind equal the precision divided by 8, rounding  
up.  Again,
Index: config/i386/mingw32.h
===================================================================
--- config/i386/mingw32.h       (revision 118930)
+++ config/i386/mingw32.h       (working copy)
@@ -116,3 +116,7 @@
/* mingw32 atexit function is safe to use in shared libraries.  Use it
     to register C++ static destructors.  */
#define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
+
+/* mingw32 doesn't have proper I/O support for long double.  */
+#undef GFORTRAN_WITHOUT_LONGDOUBLE
+#define GFORTRAN_WITHOUT_LONGDOUBLE 



More information about the Fortran mailing list