Where is stddef.h defined in Linux?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
If I want to find the values of stddef.h
, where is it defined? The /usr/include/linux/stddef.h
almost has nothing,
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef __always_inline
#define __always_inline __inline__
#endif
Specifically, I wanted to see how size_t
is defined?
linux gcc glibc
add a comment |Â
up vote
0
down vote
favorite
If I want to find the values of stddef.h
, where is it defined? The /usr/include/linux/stddef.h
almost has nothing,
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef __always_inline
#define __always_inline __inline__
#endif
Specifically, I wanted to see how size_t
is defined?
linux gcc glibc
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
If I want to find the values of stddef.h
, where is it defined? The /usr/include/linux/stddef.h
almost has nothing,
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef __always_inline
#define __always_inline __inline__
#endif
Specifically, I wanted to see how size_t
is defined?
linux gcc glibc
If I want to find the values of stddef.h
, where is it defined? The /usr/include/linux/stddef.h
almost has nothing,
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef __always_inline
#define __always_inline __inline__
#endif
Specifically, I wanted to see how size_t
is defined?
linux gcc glibc
asked Jun 22 at 7:02
Evan Carroll
4,45683472
4,45683472
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
The C standard does not distinguish compiler features from library features. The distinction is an implementation detail and can vary from platform to platform, but there are common trends. For example the size of basic integer types such as size_t
and associated macros such as CHAR_BIT
and SIZE_MAX
are properties of the compiler and compiler options; on the other hand the contents of stdio.h
are usually independent of the compiler but dependent on how the standard library implements files.
stddef.h
mostly declares compiler things, so it comes with the compiler. You'd better get different definitions if compiling in 32-bit or 64-bit mode, for instance, and you'll get different definitions with e.g. GCC and Clang. So look for it in compiler directories. Some compilers even don't have a disk file at all, they just treat the name <stddef.h>
specially, but with GCC and Clang you do get a disk file.
You can find all the copies on your system with the locate
command.
If you want to know what include path GCC is using when given particular options, pass the option -v
on the command line in additions to the other options you use in your build (especially -m
). If you just want this information without compiling anything, invoke GCC in preprocessor-only mode with empty input (-xc -E /dev/null
; you need a -x
option since GCC can't tell what language you're compiling without a file name). The same options work with Clang, by the way.
gcc -v -xc -E /dev/null 2>&1 |
awk ' /^End of search list/ exit p print /^#include <...> search starts here:/ p=1' |
xargs sh -c 'for x; do if [ -e "$x/stddef.h" ]; then echo "$x/stddef.h"; exit; fi; done' sh
If all you want to know is the definition of size_t
, then you don't need to know where it comes from. Ask the compiler to print the output of the preprocessor.
echo '#include <stddef.h>' | gcc -xc -E - | grep size_t
add a comment |Â
up vote
-2
down vote
size_t
is defined in /usr/include/sys/types.h
Note that you may need to follow #includes from that file to find the real definition.
stddef.h
is just a meta include file and the only unique definition in that file is the offsetof
macro.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The C standard does not distinguish compiler features from library features. The distinction is an implementation detail and can vary from platform to platform, but there are common trends. For example the size of basic integer types such as size_t
and associated macros such as CHAR_BIT
and SIZE_MAX
are properties of the compiler and compiler options; on the other hand the contents of stdio.h
are usually independent of the compiler but dependent on how the standard library implements files.
stddef.h
mostly declares compiler things, so it comes with the compiler. You'd better get different definitions if compiling in 32-bit or 64-bit mode, for instance, and you'll get different definitions with e.g. GCC and Clang. So look for it in compiler directories. Some compilers even don't have a disk file at all, they just treat the name <stddef.h>
specially, but with GCC and Clang you do get a disk file.
You can find all the copies on your system with the locate
command.
If you want to know what include path GCC is using when given particular options, pass the option -v
on the command line in additions to the other options you use in your build (especially -m
). If you just want this information without compiling anything, invoke GCC in preprocessor-only mode with empty input (-xc -E /dev/null
; you need a -x
option since GCC can't tell what language you're compiling without a file name). The same options work with Clang, by the way.
gcc -v -xc -E /dev/null 2>&1 |
awk ' /^End of search list/ exit p print /^#include <...> search starts here:/ p=1' |
xargs sh -c 'for x; do if [ -e "$x/stddef.h" ]; then echo "$x/stddef.h"; exit; fi; done' sh
If all you want to know is the definition of size_t
, then you don't need to know where it comes from. Ask the compiler to print the output of the preprocessor.
echo '#include <stddef.h>' | gcc -xc -E - | grep size_t
add a comment |Â
up vote
0
down vote
The C standard does not distinguish compiler features from library features. The distinction is an implementation detail and can vary from platform to platform, but there are common trends. For example the size of basic integer types such as size_t
and associated macros such as CHAR_BIT
and SIZE_MAX
are properties of the compiler and compiler options; on the other hand the contents of stdio.h
are usually independent of the compiler but dependent on how the standard library implements files.
stddef.h
mostly declares compiler things, so it comes with the compiler. You'd better get different definitions if compiling in 32-bit or 64-bit mode, for instance, and you'll get different definitions with e.g. GCC and Clang. So look for it in compiler directories. Some compilers even don't have a disk file at all, they just treat the name <stddef.h>
specially, but with GCC and Clang you do get a disk file.
You can find all the copies on your system with the locate
command.
If you want to know what include path GCC is using when given particular options, pass the option -v
on the command line in additions to the other options you use in your build (especially -m
). If you just want this information without compiling anything, invoke GCC in preprocessor-only mode with empty input (-xc -E /dev/null
; you need a -x
option since GCC can't tell what language you're compiling without a file name). The same options work with Clang, by the way.
gcc -v -xc -E /dev/null 2>&1 |
awk ' /^End of search list/ exit p print /^#include <...> search starts here:/ p=1' |
xargs sh -c 'for x; do if [ -e "$x/stddef.h" ]; then echo "$x/stddef.h"; exit; fi; done' sh
If all you want to know is the definition of size_t
, then you don't need to know where it comes from. Ask the compiler to print the output of the preprocessor.
echo '#include <stddef.h>' | gcc -xc -E - | grep size_t
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The C standard does not distinguish compiler features from library features. The distinction is an implementation detail and can vary from platform to platform, but there are common trends. For example the size of basic integer types such as size_t
and associated macros such as CHAR_BIT
and SIZE_MAX
are properties of the compiler and compiler options; on the other hand the contents of stdio.h
are usually independent of the compiler but dependent on how the standard library implements files.
stddef.h
mostly declares compiler things, so it comes with the compiler. You'd better get different definitions if compiling in 32-bit or 64-bit mode, for instance, and you'll get different definitions with e.g. GCC and Clang. So look for it in compiler directories. Some compilers even don't have a disk file at all, they just treat the name <stddef.h>
specially, but with GCC and Clang you do get a disk file.
You can find all the copies on your system with the locate
command.
If you want to know what include path GCC is using when given particular options, pass the option -v
on the command line in additions to the other options you use in your build (especially -m
). If you just want this information without compiling anything, invoke GCC in preprocessor-only mode with empty input (-xc -E /dev/null
; you need a -x
option since GCC can't tell what language you're compiling without a file name). The same options work with Clang, by the way.
gcc -v -xc -E /dev/null 2>&1 |
awk ' /^End of search list/ exit p print /^#include <...> search starts here:/ p=1' |
xargs sh -c 'for x; do if [ -e "$x/stddef.h" ]; then echo "$x/stddef.h"; exit; fi; done' sh
If all you want to know is the definition of size_t
, then you don't need to know where it comes from. Ask the compiler to print the output of the preprocessor.
echo '#include <stddef.h>' | gcc -xc -E - | grep size_t
The C standard does not distinguish compiler features from library features. The distinction is an implementation detail and can vary from platform to platform, but there are common trends. For example the size of basic integer types such as size_t
and associated macros such as CHAR_BIT
and SIZE_MAX
are properties of the compiler and compiler options; on the other hand the contents of stdio.h
are usually independent of the compiler but dependent on how the standard library implements files.
stddef.h
mostly declares compiler things, so it comes with the compiler. You'd better get different definitions if compiling in 32-bit or 64-bit mode, for instance, and you'll get different definitions with e.g. GCC and Clang. So look for it in compiler directories. Some compilers even don't have a disk file at all, they just treat the name <stddef.h>
specially, but with GCC and Clang you do get a disk file.
You can find all the copies on your system with the locate
command.
If you want to know what include path GCC is using when given particular options, pass the option -v
on the command line in additions to the other options you use in your build (especially -m
). If you just want this information without compiling anything, invoke GCC in preprocessor-only mode with empty input (-xc -E /dev/null
; you need a -x
option since GCC can't tell what language you're compiling without a file name). The same options work with Clang, by the way.
gcc -v -xc -E /dev/null 2>&1 |
awk ' /^End of search list/ exit p print /^#include <...> search starts here:/ p=1' |
xargs sh -c 'for x; do if [ -e "$x/stddef.h" ]; then echo "$x/stddef.h"; exit; fi; done' sh
If all you want to know is the definition of size_t
, then you don't need to know where it comes from. Ask the compiler to print the output of the preprocessor.
echo '#include <stddef.h>' | gcc -xc -E - | grep size_t
answered Jun 22 at 7:20
Gilles
502k1179921516
502k1179921516
add a comment |Â
add a comment |Â
up vote
-2
down vote
size_t
is defined in /usr/include/sys/types.h
Note that you may need to follow #includes from that file to find the real definition.
stddef.h
is just a meta include file and the only unique definition in that file is the offsetof
macro.
add a comment |Â
up vote
-2
down vote
size_t
is defined in /usr/include/sys/types.h
Note that you may need to follow #includes from that file to find the real definition.
stddef.h
is just a meta include file and the only unique definition in that file is the offsetof
macro.
add a comment |Â
up vote
-2
down vote
up vote
-2
down vote
size_t
is defined in /usr/include/sys/types.h
Note that you may need to follow #includes from that file to find the real definition.
stddef.h
is just a meta include file and the only unique definition in that file is the offsetof
macro.
size_t
is defined in /usr/include/sys/types.h
Note that you may need to follow #includes from that file to find the real definition.
stddef.h
is just a meta include file and the only unique definition in that file is the offsetof
macro.
edited Jun 22 at 8:25
answered Jun 22 at 7:44
schily
8,57221435
8,57221435
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451232%2fwhere-is-stddef-h-defined-in-linux%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password