【发布时间】:2015-04-24 23:11:22
【问题描述】:
我想在 CLion 中开发一些小的 linux 内核模块。比如我要编译这些文件:
stack.h:
#ifndef _LL_STACK_H
#define _LL_STACK_H
#include <linux/list.h>
typedef struct stack_entry {
struct list_head lh;
void *data;
} stack_entry_t;
stack_entry_t* create_stack_entry(void *data);
void delete_stack_entry(stack_entry_t *entry);
void stack_push(struct list_head *stack, stack_entry_t *entry);
stack_entry_t* stack_pop(struct list_head *stack);
#define stack_empty(stack) list_empty((stack))
#define STACK_DATA(stack_entry, data_ptr_type) \
((data_ptr_type)(stack_entry)->data)
#define STACK_DATA_RESET(stack_entry, new_data) \
do { \
(stack_entry)->data = new_data; \
} while(0)
#endif //_LL_STACK_H
main.c:
#include <stdio.h>
#include "stack.h"
int main() {
printf("hello");
return 0;
}
是否可以配置 CMakeLists.txt 来完成我的任务?我尝试add一些目录(linux、include、kernel),但没有成功。
【问题讨论】:
-
您是否尝试过询问 CLion 开发人员?而且,你的
main.c不属于内核编程。 -
@AndyShevchenko,还没有。我的
main.c是示例文件,其中包括stack.h,它依赖于<linux/list.h>。
标签: c linux linux-kernel cmake clion