Linux kernel environment setup in VSCode
Hey, I'm new to the Linux kernel development, and I wanted to set up a VSCode environment for navigating the code (I know, even though people tell me Vim is better but currently I'm really not comfortable with it yet). My main goal is just navigating and understanding. I've been able to make a lot work, and using the C/C++ extension from Microsoft I have good IntelliSense. However, some things are getting flagged by the extension as errors (which of course shouldn't, since I've been able to compile the kernel). These are things like: identifiers being undefined (for example, in kernel/sched/cpudeadline.c u64 is undefined) and errors like: function returning array is not allowed (for example, in drivers/md/dm-zero.c on the bottom). I'm wondering if I'm forgetting things such that all these things get resolved. Any tips are appreciated. Thanks!
Hi, C/C++ IntelliSense in conjunction with Makefile Tools extension could solve the problem Indeed, any projects built with makefile (such as Linux kernel) should use this combination in VSCode Here is an introduction of Makefile Tools https://devblogs.microsoft.com/cppblog/now-announcing-makefile-support-in-vi... I hope it helps Best, Dang
Hi Jasper, On 4/4/22 21:31, Jasper Surmont wrote:
Hey,
I'm new to the Linux kernel development, and I wanted to set up a VSCode environment for navigating the code (I know, even though people tell me Vim is better but currently I'm really not comfortable with it yet). My main goal is just navigating and understanding. I've been able to make a lot work, and using the C/C++ extension from Microsoft I have good IntelliSense.
Just don't install stock C/C++ extension. This extension can't handle the kernel, so every time you press 'go to definition' button you will get "hey, there are 20 references, one of them is 100% definition, so go ahead and find it yourself". That's why I moved to vim + ctags. It saves my time a lot. I saw, that there are other c extensions and people say they are a way better, but I didn't give them a try Good luck! With regards, Pavel Skripkin
On Mon, Apr 04, 2022 at 09:31:46PM +0300, Jasper Surmont wrote:
Hey,
I'm new to the Linux kernel development, and I wanted to set up a VSCode environment for navigating the code (I know, even though people tell me Vim is better but currently I'm really not comfortable with it yet). My main goal is just navigating and understanding. I've been able to make a lot work, and using the C/C++ extension from Microsoft I have good IntelliSense.
However, some things are getting flagged by the extension as errors (which of course shouldn't, since I've been able to compile the kernel). These are things like: identifiers being undefined (for example, in kernel/sched/cpudeadline.c u64 is undefined) and errors like: function returning array is not allowed (for example, in drivers/md/dm-zero.c on the bottom). vscode use clang and needs clangd. you can generate from ./scripts/clang-tools/gen_compile_commands.py which makes you navigate source code! I'm wondering if I'm forgetting things such that all these things get resolved. Any tips are appreciated.
Thanks!
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (4)
-
Jasper Surmont -
Kwanghoon Son -
Minh Dang -
Pavel Skripkin