zoukankan      html  css  js  c++  java
  • pid_t的类型定义 【转】

       创建进程时经常会用到进程号的类型定义:pid_t。我们都知道这个类型定义实际上就是int型。但是在linux下的c中的头文件中这个定义到底是怎么定义的呢?今天就把以前找这个定义的过程贴出来:

    1.首先在/usr/include/sys/types.h中有如下定义

    #include <bits/types.h>
         ......
       
    #ifndef __pid_t_defined
    typedef __pid_t pid_t;
    # define __pid_t_defined
    #endif
    可以看到pid_t 其实就是__pid_t类型。

    2.在/usr/include/bits/types.h中可以看到这样的定义

    #include <bits/typesizes.h>

    #if __WORDSIZE == 32
            ......
    # define __STD_TYPE        __extension__ typedef
    #elif __WORDSIZE == 64
              ......
    #endif
            ......
    __STD_TYPE __PID_T_TYPE __pid_t;    /* Type of process identifications.  */

    可以看出__pid_t 有被定义为 __extension__ typedef  __PID_T_TYPE类型的。

    3.在文件/usr/include/bits/typesizes.h中可以看到这样的定义(这个文件中没有包含任何的头文件):

    #define __PID_T_TYPE        __S32_TYPE

    可以看出__PID_T_TYPE有被定义为__S32_TYPE这种类型。

    4.在文件/usr/include/bits/types.h中我们终于找到了这样的定义:

    #define    __S32_TYPE        int

    由此我们终于找到了pid_t的真实定义:实际他就是  int  类型的。
  • 相关阅读:
    Eclipse 开发过程中利用 JavaRebel 提高效率
    数字转化为大写中文
    网页变灰
    解决QQ截图无法在PS中粘贴
    ORACLE操作表时”资源正忙,需指定nowait"的解锁方法
    网页常用代码
    SQL Server 2000 删除注册的服务器
    GridView 显示序号
    读取Excel数据到DataTable
    清除SVN版本控制
  • 原文地址:https://www.cnblogs.com/candycloud/p/3373486.html
Copyright © 2011-2022 走看看