pid_t Type in Linux It is used to define process in environment programming ID, The header file needs to be introduced <sys/types.h>, First look at the header file
/usr/include/sys/types.h About pid_t Definition of .
#ifndef __pid_t_defined typedef __pid_t pid_t; # define __pid_t_defined #endif
so pid_t Equivalent to __pid_t, Keep looking __pid_t Definition of .
Header file <sys/types.h> The header file is included in <bits/types.h>, Depending on the name, it is related to the definition of the type , We're in the header file <bits/types.h> We found it in
__pid_t Is defined as follows :
#if __WORDSIZE == 32 #define __STD_TYPE __extension__ typedef #elif __WORDSIZE
== 64 # define __STD_TYPE typedef #else # error #endif __STD_TYPE __PID_T_TYPE
__pid_t; /* Type of process identifications. */
That is to say, if we compile a program that is 32 Bit , that __pid_t Is defined as follows :
__extension__ typedef __PID_T_TYPE __pid_t;
If we compile a program that is 64 Bit , that __pid_t Is defined as follows :
typedef __PID_T_TYPE __pid_t;
among __extension__ The role of :GCC To standard C The language has been extended , But when you use these extensions , The compiler will warn you , use __extension__
Keywords will tell GCC Don't warn .
__pid_t Is equivalent to __PID_T_TYPE, We keep looking __PID_T_TYPE Definition of , In header file <bits/typesizes.h> We found that
__PID_T_TYPE Is defined as follows :
#define __PID_T_TYPE __S32_TYPE
thus , We found it pid_t Is equivalent to __S32_TYPE. that __S32_TYPE What type is it ? We go back to the header file <bits/types.h> The following definitions were found :
#define __S32_TYPE int
thus , We come to the following conclusion :
pid_t be equal to int.
Technology
Daily Recommendation