stddef.h

B

Bill Cunningham

I don't seem to have stddef.h anywhere in /usr/include. I am using an
old gcc-3.2 series and I have a gcc-3.4.6 but not installed. Does the
standard say anything about not having stddef.h ?

Bill
 
B

Bill Cunningham

But I do have wchar.h. Does gcc not fully implement ISO C or something.
As long as it conforms to ANSI I guess that's what most people work with.

Bill
 
B

Beej Jorgensen

Bill Cunningham said:
I don't seem to have stddef.h anywhere in /usr/include. I am using an
old gcc-3.2 series and I have a gcc-3.4.6 but not installed. Does the
standard say anything about not having stddef.h ?

It's probably not in /usr/include. Try "locate stddef.h", if you have
locate installed.

For instance, I have it here (though you will likely have it elsewhere):

/usr/lib/gcc/i486-slackware-linux/4.3.3/include/stddef.h

Also, if you pass the -v switch to gcc when you compile, it'll tell you
which directories it is searching:

#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-slackware-linux/4.3.3/include
/usr/lib/gcc/i486-slackware-linux/4.3.3/include-fixed
/usr/include
End of search list.

What the other guys have said about stddef.h not necessarily needing to
be a file is true. However, in your case, it probably is a file.

-Beej

Amusingly, locate found this:

/home/beej/backup/windows/40meg/lang/tc/include/stddef.h

That's a copy of Turbo C 2.0 in a backup of my old MSDOS 40 MB hard disk
in a backup of my old Windows 95 hard disk. It's turtles all the way
down!
 
L

Loïc Domaigné

Hello Bill,
    I don't seem to have stddef.h anywhere in /usr/include. I am using an
old gcc-3.2 series and I have a gcc-3.4.6 but not installed. Does the
standard say anything about not having stddef.h ?

#include <stddef.h> should work. If it is an header file, it might be
located somewhere else. For instance on one of my Linux distro, it's
located in /usr/include/linux

Cheers,
Loïc
 
L

Loïc Domaigné

Hi again,
    But I do have wchar.h. Does gcc not fully implement ISO C or something.
As long as it conforms to ANSI I guess that's what most people work with.

Hmmm... unless I am mistaken, ANSI has adopted ISO/IED 9899:1999,
oder?

Cheers,
Loïc
 
T

Thomas Zimmermann

Hi
I don't seem to have stddef.h anywhere in /usr/include.

On my system

find /usr -name "stddef.h"

says

/usr/include/linux/stddef.h
/usr/include/xulrunner-sdk-1.9.1/system_wrappers/stddef.h
/usr/include/xulrunner-sdk-1.9.1/system_wrappers_js/stddef.h
/usr/src/kernels/2.6.29.6-217.2.7.fc11.x86_64/include/linux/stddef.h
/usr/src/kernels/2.6.29.6-217.2.3.fc11.x86_64/include/linux/stddef.h
/usr/lib/gcc/x86_64-redhat-linux/4.4.0/include/stddef.h
/usr/share/syslinux/com32/include/stddef.h
/usr/share/syslinux/com32/include/bitsize/stddef.h

Number six looks like the one that gets included.

Thomas
 
B

Bill Cunningham

Thomas Zimmermann said:
Hi


On my system

find /usr -name "stddef.h"
[snip]

I used find / "stddef.h" -name -print. Find wanted an option to name. find
didn't find anything.
 
B

Bill Cunningham

Thomas Zimmermann said:
Hi


On my system

find /usr -name "stddef.h"

says

[snip]

OK found it. I must've been using find wrong. My system says this:

/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h
/usr/include/linux/stddef.h

So there are two locations here.

Bill
 
N

Nobody

OK found it. I must've been using find wrong. My system says this:

/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h
/usr/include/linux/stddef.h

So there are two locations here.

The first one is what "#include <stddef.h>" will use. Headers which are
intimately tied to gcc (rather than libc) go in /usr/lib/gcc-lib (or
/usr/lib/gcc for newer versions).

The second one just defines NULL for use in the Linux kernel (which
can't use <stdio.h>, which is where NULL is normally defined).
 
K

Keith Thompson

Bill Cunningham said:
Thomas Zimmermann said:
On my system

find /usr -name "stddef.h"

says

[snip]

OK found it. I must've been using find wrong. My system says this:

/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h
/usr/include/linux/stddef.h

So there are two locations here.

And there's no good reason why you should care which one is used,
or whether your compiler uses some other file or even some entirely
different mechanism.

The standard specifies that "#include <stddef.h>" works. It doesn't
specify how it works.

(If you care about the inner workings of your implementation, there
are ways to ask gcc to give you more information about what files
it's reading as it compiles your source file.)
 
K

Keith Thompson

Nobody said:
The first one is what "#include <stddef.h>" will use. Headers which are
intimately tied to gcc (rather than libc) go in /usr/lib/gcc-lib (or
/usr/lib/gcc for newer versions).

I'll assume that's accurate, but it's not something that's defined by
the language, nor is it something that the OP needs to worry about.
The second one just defines NULL for use in the Linux kernel (which
can't use <stdio.h>, which is where NULL is normally defined).

NULL is required to be defined in several standard headers, namely:

<locale.h>
<stddef.h>
<stdio.h>
<stdlib.h>
<string.h>
<time.h>
<wchar.h>
 
D

David Thompson

It's probably not in /usr/include. Try "locate stddef.h", if you have
locate installed.

For instance, I have it here (though you will likely have it elsewhere):

/usr/lib/gcc/i486-slackware-linux/4.3.3/include/stddef.h
To be clear, _gcc_ (usually) puts 'fixed' versions of standard headers
under lib/gcc/$config/$version/include. Other compilers don't.
On Unixes that have or allow for other compilers (some do) headers
almost always _will_ be under /usr/include (sometimes a subdirectory).
On nonUnix systems using other than gcc, it varies. Lots.
Also, if you pass the -v switch to gcc when you compile, it'll tell you

among (many!) other things
which directories it is searching:

#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-slackware-linux/4.3.3/include
/usr/lib/gcc/i486-slackware-linux/4.3.3/include-fixed
/usr/include
End of search list.
And if you use -E the preprocessed output will contain #=line
directives that identify the file actually selected by this search.
(But it won't actually do the compilation with the option.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top