Search code examples
cvisual-studiovisual-studio-2013visual-studio-2017

using linux header files in visual studio


I was trying to use linux kernel header file on the visual studio 2013. I want to do this for auto completion purpose.

I noticed that stdio.h file is inside of the C:\Program Files\Visual Studio 12.0\VC\crt\src, So I copied my linux folder, which contains kernel header files, into the src folder. However, Visual studio does not seem to find these header files.

For example: #include <linux/kernel.h>

It says Error: cannot open source file "linux/kernel.h"

I tried to change all slash characters into back slash, however, it does not fix the issue. What do I have to do if I want to make visual studio know this header file is existed?

I know I could move my kernel.h to my current folder and use #include "kernel.h"

However, I would like to keep the system header files in my computer and use with #include <linux/kernel.h> when it is needed.


Solution

  • #include <kernel.h>
    

    and add C:\Program Files\Visual Studio 12.0\VC\crt\src\linux to the include path (if one is using VS2017 which shipped with it).

    To obtain the kernel.h file, i.e. kernel source, determine the kernel version one needs and obtain the src from kernel.org, e.g. 5.4.26