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

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

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

If it's not in C std, does GCC just do some magic to make things work?

Thanks Chenz

+3
source share
6 answers

From draft C99:

7.17 General definitions <stddef.h>

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

  • Types: [-snip -]

    size_t
    

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

+4
source

size_t <stddef.h>, <stdlib.h>

+5

size_t C

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

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

will give you a list of files that define size_t

+1
source

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

0
source

It is defined in string.h in ansi c.

0
source

Source: https://habr.com/ru/post/1739189/


All Articles