Re: what is stdinc and how can I get where it is ?

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

You haven't written what kind of environment you are using, so I in
the later I will assume it is linux or BSD. See my comments below.

loody írta:
> Dear all:
> in gcc document there is an option as
> -nostdinc
> Do not search the standard system directories for header
> files.  Only the directories you have specified with -I
> options  (and the directory of the current file, if appropriate)
> are searched
> Is that used to tell where the headers that gcc can get the size of
> some already define data types?
Unless you are a kernel developer you shouldn't use -nostdinc, because
gcc will not found essential header files.
By default as you have written, gcc is looking for header files in the
following locations (maybe in different order):

o standard system directories:
 - this is the directory where standard headers installed, and this
location is the same for the whole system and cannot be changed.
 - this directory is usually /usr/include and /usr/local/include on a
Unix like system.
 - you can change the location of standard system directory with
$C_INCLUDE_PATH and $CPLUS_INCLUDE_PATH env. variables.
 - if this directory is empty it means that you don't have installed
your development environment properly eg. libc/glibc is not installed
which is the standard C library.

o In directory where your source code is. These headers are part of
your program.

o In directories you specified with -I.. command line options. These
headers are usually not part of your program (or not in the same
directory) neither a system wide library. E.g.: a library you have
downloaded but have not installed system wide, or if you want to use a
library which has different version than the one installed on your system.

So if you use -nostdinc, gcc simply ignores the standard headers. This
is only useful if you are writing a program which doesn't use standard
library at all, or you want to use a different standard library and in
this case you must tell its location to gcc with -I/path/to/your/headers.
> If my assumption is correct, is there any command or options I can use
> to check where is the path that my gcc search for, since I always get
> error messages as "cannot find stddef.h" ?
> I have type "gcc -v" but i have no idea which one can tell me where
> the stdinc path it looks for?
> appreciate your help,
> miloody
I dont know how to get them in an exact way, but I'm pretty sure gcc
will look in the directories I wrote above. But be careful, if you use
- -nostdinc, it will skip system headers!

stddef.h is not part of glibc, but part of gcc itself, and on my
system it is located in a compiler specific directory. I used gcc -v
and looked for --includedir=... to get its path, but it didn't tell me
the location of standard header files. Maybe it is "include" added to
the path specified with --prefix=... ? I'm not sure.

Have a nice day,
Tibor
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksJiYUACgkQRH5UCDZswS0YOACfYaQcnsdeFQtjGrStkPAm7GFO
G0AAoMNC/k+rnWzFCrMxKst4kUUrayU0
=1Lbz
-----END PGP SIGNATURE-----


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux