首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android内核构建错误: core_ctl.c -取消引用指向不完整类型的指针

问Android内核构建错误: core_ctl.c -取消引用指向不完整类型的指针
EN

Stack Overflow用户
提问于 2017-08-07 15:01:42
回答 1查看 233关注 0票数 0

这个内核使用ARM的GCC工具链构建得很好..由于某些原因,aarch64工具链抛出了这个错误。

代码语言:javascript
复制
kernel/sched/core_ctl.c: In function 'cpufreq_gov_cb':
kernel/sched/core_ctl.c:1086:25: error: dereferencing pointer to incomplete type
   core_ctl_set_busy(info->cpu, info->load);
                         ^
kernel/sched/core_ctl.c:1086:36: error: dereferencing pointer to incomplete type
   core_ctl_set_busy(info->cpu, info->load);
                                    ^
scripts/Makefile.build:257: recipe for target 'kernel/sched/core_ctl.o' failed

下面是定义"cpu“的文件开头的结构(在c文件中找不到load ):

代码语言:javascript
复制
#include <linux/init.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/cpufreq.h>
#include <linux/timer.h>
#include <linux/kthread.h>
#include <linux/sched.h>
#include <linux/sched/rt.h>
#include <linux/mutex.h>

#include <trace/events/sched.h>

#define MAX_CPUS_PER_GROUP 4

struct cpu_data {
    /* Per CPU data. */
    bool    inited;
    bool    online;
    bool    rejected;
    bool    is_busy;
    bool    not_preferred;
    unsigned int busy;
    unsigned int cpu;
    struct list_head sib;
    unsigned int first_cpu;
    struct list_head pending_sib;

    /* Per cluster data set only on first CPU */
    unsigned int min_cpus;
    unsigned int max_cpus;
    unsigned int offline_delay_ms;
    unsigned int busy_up_thres[MAX_CPUS_PER_GROUP];
    unsigned int busy_down_thres[MAX_CPUS_PER_GROUP];
    unsigned int online_cpus;
    unsigned int avail_cpus;
    unsigned int num_cpus;
    unsigned int need_cpus;
    unsigned int task_thres;
    s64 need_ts;
    struct list_head lru;
    bool pending;
    spinlock_t pending_lock;
    bool is_big_cluster;
    int nrrun;
    bool nrrun_changed;
    struct timer_list timer;
    struct task_struct *hotplug_thread;
    struct kobject kobj;
    struct list_head pending_lru;
    bool disabled;
};

是什么让编译器报告不完整的类型?我还不太熟悉C中的指针和结构。弄不清楚。

EN

回答 1

Stack Overflow用户

发布于 2017-08-09 14:18:24

在您的机器上编译cpufreq_govinfo /sched/core_ctl.c时,似乎缺少结构核心的头文件。

代码语言:javascript
复制
struct cpufreq_govinfo {
 unsigned int cpu;
 unsigned int load;
 unsigned int sampling_rate_us;
};

在我的机器(ARM:CortexA7)上,GCC编译器没有抛出编译错误,因为正确地包含了以下头文件。

代码语言:javascript
复制
  kernel/include/linux/cpufreq.h

此外,下面的补丁将使您能够在构建Linux内核后对文件进行预处理。

代码语言:javascript
复制
diff --git a/Makefile b/Makefile
index b03ca98..f52240c 100644
--- a/Makefile
+++ b/Makefile
@@ -406,6 +406,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common \
                   -Werror-implicit-function-declaration \
                   -Wno-format-security \
+                  -save-temps=obj \
                   -std=gnu89

如果查看预处理文件.tmp_core_ctl.i,您将能够看到用于编译core_ctl.c的所有头文件

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45541063

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档