when you create a process, you often use the type definition of the process number: pid_t. We all know that this type definition is actually an int type. But how is this definition defined in the header file in C under Linux? Today, the process of finding this definition has been posted:
1. First, the following definitions are in/usr/include/sys/types.h
#include
......
#ifndef __pid_t_defined
typedef __pid_t PID_T;
# define __pid_t_defined
#endif
You can see that pid_t is actually the __pid_t type.
2. This definition can be seen in the/usr/include/bits/types.h
#include
#if __wordsize = = 32
......
# define __std_type __extension__ typedef
#elif __wordsize = = 64
......
#endif
......
__std_type __pid_t_type __pid_t; /* Type of process identifications. */
It can be seen that __pid_t has a type defined as __extension__ typedef __pid_t_type.
3. You can see this definition in the file/usr/include/bits/typesizes.h (this file does not contain any header files):
#define __pid_t_type __s32_type
It can be seen that __pid_t_type has a type that is defined as __s32_type.
4. In the document/USR/INCLUDE/BITS/TYPES.H we finally found the definition:
#define __S32_TYPE INT
So we finally found the true definition of pid_t: The actual he is the int type.
This article is from the "canvas shoes can walk the cat step" blog, please be sure to keep this source http://9409270.blog.51cto.com/9399270/1870011
The type definition of the process number pid_t