Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c

size-t

Is size_t 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

like image 758
Crazy Chenz Avatar asked Dec 18 '22 01:12

Crazy Chenz


2 Answers

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

like image 192
James McNellis Avatar answered Dec 24 '22 01:12

James McNellis


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-]

like image 31
kennytm Avatar answered Dec 24 '22 01:12

kennytm