开发者

Is size_t only in C++ standard or C standard as well?

Is size_t开发者_如何学C only in C++ standard or C standard as well?

I cannot find a C header in the "/usr/include" tree that defines size_t.

If it is not in the C std, is GCC just doing some magic to make things work?

Thanks, Chenz


size_t is defined in both <stddef.h> and <stdlib.h>


From C99 draft:

7.17 Common definitions <stddef.h>

  1. The following types and macros are defined in the standard header <stddef.h>. Some are also defined in other headers, as noted in their respective subclauses.

  2. The types are [-snip-]

    size_t
    

    which is the unsigned integer type of the result of the sizeof operator; [-snip-]


size_t is from the C standard library

It is declared in

#include <stddef.h>  //For C
#include <cstddef>   //For C++


$ grep -R -P "typedef.*\s+size_t;" /usr/include/ 2> /dev/null

will give you a list of files that define size_t


size_t is in stdlib.h for C (or cstdlib.h in C++).


It is defined in string.h in ansi c.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜