#if does not work!

Unga unga888@yahoo.com
Sat Jun 21 14:03:00 GMT 2008


--- On Sat, 6/21/08, Andrew Haley <aph@redhat.com> wrote:

> From: Andrew Haley <aph@redhat.com>
> Subject: Re: #if does not work!
> To: unga888@yahoo.com
> Cc: gcc-help@gcc.gnu.org
> Date: Saturday, June 21, 2008, 8:14 PM
> Unga wrote:
> > --- On Sat, 6/21/08, Andrew Haley
> <aph@redhat.com> wrote:
> >
> > Here is a test case:
> >
> > #include <stdio.h>
> > #include <float.h>
> >
> > main()
> > {
> >  printf("%d\n", LDBL_MANT_DIG);
> > }
> >
> >
> > In float.h, the LDBL_MANT_DIG is defined as:
> > #define LDBL_MANT_DIG   64
> >
> > I compile the above test program as:
> > gcc -I/tools/include -I/tools/usr/include -o test
> test.c
> >
> > ./test prints 53!!!!
> >
> > The reason is, it is not taking the float.h from
> /tools/usr/include,
> > but from
> >
> /tools/lib/gcc/i386-unknown-freebsd7.0/4.3.1/include/float.h
> .
> 
> Yeah, this is right: gcc sometimes needs its own fixed
> versions of standard headers.
> 
> > Rename the
> >
> /tools/lib/gcc/i386-unknown-freebsd7.0/4.3.1/include/float.h
> to
> > something else and compile the test.c and run prints
> 64.
> >
> > Programs I compile should get their header files only
> from
> > /tools/include and /tools/usr/include.
> 
> Well, that would mean that you would not be able to access
> the
> system's C library at all.  Do I take it that you have
> an entire C
> library installed in /tools?  If so, that is a really weird
> thing to
> do and I son't know where you're going with it.
>

Yep, the entire C library  and system headers are installed under /tools :) What I'm doing is bit of weird and very experimental. 


> > 1. How do I instruct the gcc to get headers only from
> directories I
> > want?
> 
> Either provide full paths in your #include or use
> -nostdinc.
> Try using #include "float.h" not #include
> <float.h>.
> 
> > 2. Do I need
> /tools/lib/gcc/i386-unknown-freebsd7.0/4.3.1/include/
> > anymore? Can I either remove or rename after the gcc
> is installed?
> 
> You probably do, yes.  But bypassing your system's C
> library's headers
> is so fraught with potential problems it's hard to be
> sure.
> 

Since now I know the cause, let me try few alternatives. Thanks again for your reply.

Regards
Unga


      



More information about the Gcc-help mailing list