• Uncategorized

About c : Linux-Kernel-how-to-import-LISTHEADINIT

Question Detail

I am using the source code from git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git .

The absolute path of my file is /home/user/repos/linux/drivers/infiniband/hw/irdma/test_pble.c .

The file contains the following code.

#include "pble.c"
#include "list.h"

int main(void) {
    struct irdma_pble_prm first = {
        .clist = LIST_HEAD_INIT{first.clist};
}

LIST_HEAD_INIT is declared in /home/user/repos/linux/include/linux/list.h .
My IDE CLion gives me the following warning: Use of undeclared identifier ‘LIST_HEAD_INIT’.
How can I correctly import the macro LIST_HEAD_INIT?

Question Answer

#include "linux/list.h" if they are stored in the directory with your project. Although, you probably want to include the directory the linux headers are in as a system header with -isystem /path/to/include/ compiler flag (or in your IDE) so you can do #include <linux/list.h>

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.