[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C compilation questions

On Fri, Dec 29, 2000 at 08:29:12AM -0800, Sean 'Shaleh' Perry wrote:

> > The second problem seems to be one of policy.  I get a warning:
> > In file included from /usr/include/math.h:33,
> > from lufactor.c:37:
> > /usr/include/bits/huge_val.h:37: warning: HUGE_VAL' redefined
> >  machine.h:216: warning: this is the location of the previous definition
> > 
> > This happens because the source file in question has: 
> >#include        "matrix.h" 
> >#include        <math.h> 
> > 
> > Meschach header file matrix.h defines HUGE_VAL if it isn't already defined,
> > while the standard header math.h also defines it.  This can of course be
> > resolved by simply changing the order:
> >#include        <math.h> 
> >#include        "matrix.h" 
> > 
> > So my question here is how much of a problem is this?  Should it be (or is
> > it) official policy somewhere that standard headers should always be given
> > before local headers?
> > 
> since it checks if it is defined and only defines it if not, then I would flop
> the two.  Is the one the code needs bigger than the system?

No, it seems the authors were simply careless with their #include
statements.  The actual local definition is simply:

/* for non-ANSI systems */ 
#ifndef HUGE_VAL 
#define HUGE_VAL HUGE 
#ifndef HUGE 
#define HUGE HUGE_VAL 

On my current system (gcc 2.95.2), HUGE = FLTMAX = 3.40282347e+38F
while HUGE_VAL is defined as

#if __GNUC_PREREQ(2,96) 
# define HUGE_VAL       (__extension__ 0x1.0p2047) 
# define __HUGE_VAL_bytes       { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } 
 # define __huge_val_t   union { unsigned char __c[8]; double __d; }  
 # ifdef __GNUC__  
 #  define HUGE_VAL      (__extension__ \  
                          ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d)  ,

whatever that means.

I suspect the authors don't really care about the subtleties of the
definition of HUGE_VAL, just so long as it's there (they haven't actually
touched the code in years).

They put <math.h> behind "matrix.h" in nearly all their source files, so
every single one would have to be changed, which is rather annoying.  But I
guess it should be done.


PGP public key available at http://dparsons.webjump.com/drewskey.txt
Fingerprint: A110 EAE1 D7D2 8076 5FE0  EC0A B6CE 7041 6412 4E4A

Reply to: