This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fix aix build error with math.h in gcc/sreal.c


> On Tue, Dec 16, 2014 at 5:04 PM, Michael Haubenwallner
> <michael.haubenwallner@ssi-schaefer.com> wrote:
> > Recent commit 218765 adding sreal::to_double() breaks on AIX due to math.h
> > being included before _LARGE_FILES and __STDC_FORMAT_MACROS being defined
> > later in config.h and system.h, respectively.
> 
> sreal.c shouldn't include math.h, if really really really needed
> math.h needs to be
> included from system.h at the appropriate place.

Hmm, I need math.h for the exponential function. genautomata is also including math.h.
Should we thus move it to system.h

Something like this?

Since i do not caremuch about performance of to_double, we could also just have loop
that multiplies/divides by 2 until exponent is reached. It is rather lame though.

Honza

Index: system.h
===================================================================
--- system.h    (revision 218788)
+++ system.h    (working copy)
@@ -45,6 +45,8 @@
 
 #include <stdio.h>
 
+#include <math.h>
+
 /* Define a generic NULL if one hasn't already been defined.  */
 #ifndef NULL
 #define NULL 0
Index: genautomata.c
===================================================================
--- genautomata.c       (revision 218788)
+++ genautomata.c       (working copy)
@@ -113,7 +113,6 @@
 #include "errors.h"
 #include "gensupport.h"
 
-#include <math.h>
 #include "hashtab.h"
 #include "vec.h"
 #include "fnmatch.h"
Index: sreal.c
===================================================================
--- sreal.c     (revision 218788)
+++ sreal.c     (working copy)
@@ -49,7 +49,6 @@
 
 #include "config.h"
 #include "system.h"
-#include <math.h>
 #include "coretypes.h"
 #include "sreal.h"
 

> 
> Richard,
> 
> > 2014-12-16  Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
> >
> >         Both config.h and system.h define ABI/API macros for system headers.
> >         * sreal.c: Include math.h later.
> >
> > Thanks!
> > /haubi/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]