Linux カーネル空間であるメモリの割り当てに問題があります。以下の 2 つの構造体を使用してリンク リストを作成しました。
struct Node{
char *ptr;
struct Node *next;
};
struct List{
struct Node *head;
struct Node *tail;
};
リスト構造体を割り当てようとすると[適切なコードを反映するように編集]:
struct List *ll = kmalloc(sizeof(struct List), GFP_KERNEL)
私は得る:
error: Initializer element is not constant
ここで何が間違っていますか?List 構造体にノードへのポインターを追加したいので、次のように追加します。
struct Node n* = kmalloc(sizeof(Node));
n -> ptr = "Blah";
n -> next = NULL;
ll -> head = n;