You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PintOS虚拟内存项目编译预处理问题求助:类型识别异常

PintOS虚拟内存模块编译预处理问题求助

我是正在进行PintOS项目实践的学生,在虚拟内存(Programming Project 3)模块开发时,遇到了C程序编译预处理相关的问题,尝试多种方法后仍无法解决,特此求助。

问题1:spt字段被识别为不完整类型

完成栈扩展功能后,修改syscall.c实现mmap时编译出错:spt字段被识别为不完整类型。
相关thread结构体定义在thread.h中,其成员spt的类型supplemental_page_table定义于vm.h,且在thread.h的thread结构体上方已通过#ifdef VM #include "vm/vm.h"引入vm.h。我使用SSH连接Ubuntu 18.04的EC2服务器开发,尝试过make clean、调整头文件引入顺序、添加前置声明、重启重装服务器等操作,均无进展。

编译错误信息如下:

In file included from ../../include/userprog/process.h:4:0,
                 from ../../include/vm/vm.h:7,
                 from ../../vm/vm.c:4:
../../include/threads/thread.h:151:33: error: field ‘spt’ has incomplete type
  struct supplemental_page_table spt;
                                 ^~~

问题2:tid_t类型引用异常

process.h中使用的自定义类型tid_t已在thread.h中定义,且已引入thread.h,但无法被识别,只能在process.h中重复定义才能解决问题,该问题出现于上述问题之前。

相关编译错误信息:

In file included from ../../include/vm/vm.h:7:0,
                 from ../../include/threads/thread.h:12,
                 from ../../threads/init.c:24:
../../include/userprog/process.h:9:1: error: unknown type name ‘tid_t’; did you mean ‘size_t’?
 tid_t process_create_initd (const char *file_name);
 ^~~~~
 size_t

此外附上我实现mmap/munmap的代码片段,项目仓库当前分支为DJ,后续会推送包含错误状态的代码。

内容的提问来源于stack exchange,提问作者DJ Kim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 02:17:57