【问题标题】:Incompatible pointer type warning in os161 [duplicate]os161中不兼容的指针类型警告[重复]
【发布时间】:2020-03-13 23:24:15
【问题描述】:

我正在 os161 内核中实现一个 fork 系统调用。我正在尝试创建一个新进程,并使用thread_fork 创建它的线程。我正在使用函数md_forkentry将堆和堆栈分配给新线程的trapframe并切换到用户模式;但是在编译代码后我收到了这个警告: passing arg 4 of 'thread_fork' from incompatible pointer type

//Function Prototypes
int thread_fork(const char* name,void* data1,unsgined long data2,void (*func) (void*,unsigned long),struct thread **ret)
void md_forkentry(struct trapframe* tf,unsigned long n);

//the code 
struct trapframe* tf;
struct thread* child_thread;
//line I get the error from
int result=thread_fork("Child Process",(void*) tf,0,&md_forkentry,&child_thread);

【问题讨论】:

    标签: c operating-system os161


    【解决方案1】:

    md_forkentry() 的原型与thread_fork() 的第四个参数的类型不匹配。

    md_forkentry() 的原型必须为:

    void md_forkentry(void *, unsigned long);
    

    (反之亦然,即在必要时修复thread_fork()原型中给出的参数类型)

    【讨论】:

      猜你喜欢
      • 2015-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-16
      • 1970-01-01
      相关资源
      最近更新 更多