-2

where is the type size_t defined what are the other types like this , Is there a reference of the all the user defined types and data structures in linux (gcc) . for example a reference guide on

  • sockaddr_in6
  • sockaddr_in
  • mm_struct
  • pci_dev
  • sk_buff
  • tq_struct

...

cc4re
  • 4,821
  • 3
  • 20
  • 27
  • ``, `ptrdiff_t`, `max_align_t`, ... And `size_t` is certainly not `unsigned int` here, nor on most 64-bit systems. – Daniel Fischer May 01 '13 at 14:27
  • 4
    @KingsIndian: That searches every `stddef.h` file on your system; not all of them are necessarily relevant. It can also take a very long time, especially if your system mounts NFS filesystems. And it won't resolve other files included by `stddef.h>`. This works for me: `echo '#include ' | gcc -E - | grep size_t` – Keith Thompson May 01 '13 at 14:59
  • @KeithThompson Nice. That's a clever way of letting gcc do the seach for you ;-) – P.P May 01 '13 at 15:18

1 Answers1

2

The definitive reference is the standard.

The C standard defines size_t and says it's defined in <stddef.h> (on GNU/Linux that header is provided by GCC) and POSIX requires it to be defined after including <sys/types.h>

The POSIX standard defines sockaddr_in6 in <netinet/in.h>

also for eg : size_t, which is typically an unsigned int , why we define > size_t val ; rather than unsigned int val ;

Because it might not be unsigned int. On my platform it's unsigned long, so by writing size_t you get a type guaranteed to be able to represent the necessary range of values. Using unsigned int doesn't guarantee that.

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521