奇怪的错误(解除指向不完整类型的指针) [英] Strange error(dereferencing pointer to incomplete type)

查看:571
本文介绍了奇怪的错误(解除指向不完整类型的指针)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  void get_cwd(char * buf)
{
char * result;

current-> fs-> pwd;
result = get_dentry_path(current-> fs-> pwd);

memcpy(buf,result,strlen(result)+1);

kfree(result);
}

错误:解除指向不完整类型的指针

错误指向current-> fs-> pwd;

包括:

  #include< asm / stat.h> 
#include< linux / fs.h>
#include< linux / file.h>
#include< linux / module.h>
#include< linux / kernel.h>
#include< linux / string.h>
#include< linux / dirent.h>
#include< linux / sched.h>
#include< asm / uaccess.h>
#include< asm / current.h>
#include< linux / path.h>

如果我输入current-> fs;在第5行gcc不要给这行错误。问题出在 pwd 字段。

解决方案

陈旧,但我又碰到同样的问题,试图在内核v2.6.33中实现 getcwd 。由于这是在搜索取消引用指向不完整类型current-> fs时出现的最相关结果,因此最好有解决方案以供将来参考。



<解决方案是包含这两个头文件:

  #include< linux / sched.h> 
#include< linux / fs_struct.h>


void get_cwd(char* buf)
{
    char *result;

  current->fs->pwd;
    result = get_dentry_path(current->fs->pwd);

    memcpy(buf, result, strlen(result)+1);

    kfree(result);
}

error: dereferencing pointer to incomplete type

The error points to current->fs->pwd;

includes:

#include <asm/stat.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/dirent.h>
#include <linux/sched.h>
#include <asm/uaccess.h>
#include <asm/current.h>
#include <linux/path.h>

If I type current->fs; on 5th line gcc don't give error on this line. The problem is with pwd field.

解决方案

This question is kind of stale but I ran into the same issue again trying to implement getcwd in kernel v2.6.33. Since this is the most relevant result that comes up when searched for "dereferencing pointer to incomplete type current->fs", it would be good to have the solution for future reference.

The solution is to include both of these headers:

#include <linux/sched.h>
#include <linux/fs_struct.h>

这篇关于奇怪的错误(解除指向不完整类型的指针)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆