diff mbox

[Fortran] : Fix libgfortran.h error for VMS

Message ID A484518E-9110-4764-A022-086F3DFB9737@adacore.com
State New
Headers show

Commit Message

Tristan Gingold April 3, 2012, 12:42 p.m. UTC
Hi,

unfortunately VMS doesn't like to include complex.h after math.h, while the reverse is allowed.
The reason is that math.h (unless ANSI_C_SOURCE is defined but that hides many math functions) declares cabs/cabsf/cabsl for a structure representing a complex number, which is not compatible with the declarations in complex.h

The simplest path is simply to reverse the include order in libgfortran.h.  I know that this is somewhat VMS specific, and I welcome better ideas.

Tested by building gfortran for x86_64-darwin and ia64-hp-openvms.

Ok for trunk ?

Tristan.

libgfortran/
2012-04-03  Tristan Gingold  <gingold@adacore.com>

	* libgfortran.h: Include complex.h before math.h

Comments

Tobias Burnus April 3, 2012, 3:53 p.m. UTC | #1
On 04/03/2012 02:42 PM, Tristan Gingold wrote:
> The simplest path is simply to reverse the include order in libgfortran.h.  I know that this is somewhat VMS specific, and I welcome better ideas.

Well, changing the order is not that bad than one has to try hard to  
find a better solution. (Unless, it fails on other systems with the new 
order.)

> Tested by building gfortran for x86_64-darwin and ia64-hp-openvms.

OK. Thanks for the patch.

Tobias
Tristan Gingold April 4, 2012, 7:52 a.m. UTC | #2
On Apr 3, 2012, at 5:53 PM, Tobias Burnus wrote:

> 
> On 04/03/2012 02:42 PM, Tristan Gingold wrote:
>> The simplest path is simply to reverse the include order in libgfortran.h.  I know that this is somewhat VMS specific, and I welcome better ideas.
> 
> Well, changing the order is not that bad than one has to try hard to  find a better solution. (Unless, it fails on other systems with the new order.)

I cross my fingers!

>> Tested by building gfortran for x86_64-darwin and ia64-hp-openvms.
> 
> OK. Thanks for the patch.

You're welcome.  This was my latest patch to make gfortran build for VMS.  AFAIK, this is now the only post F95 fortran compiler available for VMS, although I suppose it lacks some DEC extensions specific to VMS.

Tristan.
diff mbox

Patch

diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index be5f133..ea20e14 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -42,11 +42,19 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include "config.h"
 
 #include <stdio.h>
-#include <math.h>
 #include <stddef.h>
 #include <float.h>
 #include <stdarg.h>
 
+#if HAVE_COMPLEX_H
+/* Must appear before math.h on VMS systems.  */
+# include <complex.h>
+#else
+#define complex __complex__
+#endif
+
+#include <math.h>
+
 /* If we're support quad-precision floating-point type, include the
    header to our support library.  */
 #ifdef HAVE_FLOAT128
@@ -66,12 +74,6 @@  extern long double __strtold (const char *, char **);
 #define gfc_strtold strtold
 #endif
 
-#if HAVE_COMPLEX_H
-# include <complex.h>
-#else
-#define complex __complex__
-#endif
-
 #include "../gcc/fortran/libgfortran.h"
 
 #include "c99_protos.h"