【问题标题】:Missing type information in parameters in MINIX 3 (v3.1.0)MINIX 3 (v3.1.0) 中的参数中缺少类型信息
【发布时间】:2018-12-29 17:13:19
【问题描述】:

在kernel/proto.h 中,MINIX 3 定义了两个前向声明struct proc 和struct timer。然而,参数中的许多类型信息都丢失了。 clock_t、U16_t、tmr_func_t 和 message 等示例完全缺失。文件中似乎也没有任何#include 语句,那编译器怎么不报错呢?

【问题讨论】:

  • 它可能不适合直接包含。
  • 前向声明怎么会在里面?
  • 我怎么知道?检查源代码树的其余部分;)

标签: c types minix


【解决方案1】:

查看kernel/kernel.h,很明显包含某些头文件的顺序很重要。

/* Important kernel header files. */
#include "config.h"     /* configuration, MUST be first */
#include "const.h"      /* constants, MUST be second */
#include "type.h"       /* type definitions, MUST be third */
#include "proto.h"      /* function prototypes */
#include "glo.h"        /* global variables */
#include "ipc.h"        /* IPC constants */
#include "debug.h"      /* debugging, MUST be last kernel header */

并非每个头文件都会包含它所依赖的所有其他头文件。学习使用本地搜索工具。此外,谷歌搜索clock_t 可能会很有启发性。您提到的其他大多数似乎都不是标准 C 库类型。

【讨论】:

    【解决方案2】:

    该头文件包含在验证所提到的缺失类型的其他头文件中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-19
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      • 2016-06-13
      • 1970-01-01
      • 1970-01-01
      • 2011-12-29
      相关资源
      最近更新 更多