Where is stddef.h defined in Linux?

The name of the pictureThe name of the pictureThe name of the pictureClash 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?







share|improve this question























    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?







    share|improve this question





















      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?







      share|improve this question











      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?









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jun 22 at 7:02









      Evan Carroll

      4,45683472




      4,45683472




















          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





          share|improve this answer




























            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.






            share|improve this answer























              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "106"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );








               

              draft saved


              draft discarded


















              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






























              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





              share|improve this answer

























                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





                share|improve this answer























                  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





                  share|improve this answer













                  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






                  share|improve this answer













                  share|improve this answer



                  share|improve this answer











                  answered Jun 22 at 7:20









                  Gilles

                  502k1179921516




                  502k1179921516






















                      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.






                      share|improve this answer



























                        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.






                        share|improve this answer

























                          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.






                          share|improve this answer















                          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.







                          share|improve this answer















                          share|improve this answer



                          share|improve this answer








                          edited Jun 22 at 8:25


























                          answered Jun 22 at 7:44









                          schily

                          8,57221435




                          8,57221435






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              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













































































                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?