为什么 VSCode 的 Intellisense 无法解析 #if defined(__GNUC__)?
Why is VSCode's Intellisense unable to parse #if defined(__GNUC__)?
我使用 Atom、CLion 进行内核模块开发,我想尝试 VSCode。
Intellisense 找不到某些类型和宏,例如所有 uint*_t
、u*
、dev_t
、DECLARE_BITMAP()
.
快速查看types.h
后,似乎所有这些types/macros都是在#if defined(__GNUC__)
之后定义的。
- 这是一个已知问题吗?
- 如何解决?内核头文件中充满了
#if defined()
.
这是我的c_cpp_properties.json:
{
"configurations": [
{
"defines": [
"__GNUC__",
"__KERNEL__",
"_GNU_SOURCE",
"MODULE",
],
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/include/**",
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/arch/x86/include/**"
],
"compilerPath": "/opt/rh/devtoolset-7/root/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Linux 内核有许多 头文件 具有 相同的名称 ,但位于不同的目录中。这些文件的确切路径非常重要。
出于这个原因,最好不要“glob”(使用终止 /**
)包含 Linux 内核的目录,而是编写 exact 的目录:
"includePath": [
# You could glob include directories for your module
"${workspaceFolder}/**",
# .. but do not glob Linux kernel ones
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/include",
# Do not glob arch-specific include directories for Linux kernel too
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/arch/x86/include"
],
我使用 Atom、CLion 进行内核模块开发,我想尝试 VSCode。
Intellisense 找不到某些类型和宏,例如所有 uint*_t
、u*
、dev_t
、DECLARE_BITMAP()
.
快速查看types.h
后,似乎所有这些types/macros都是在#if defined(__GNUC__)
之后定义的。
- 这是一个已知问题吗?
- 如何解决?内核头文件中充满了
#if defined()
.
这是我的c_cpp_properties.json:
{
"configurations": [
{
"defines": [
"__GNUC__",
"__KERNEL__",
"_GNU_SOURCE",
"MODULE",
],
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/include/**",
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/arch/x86/include/**"
],
"compilerPath": "/opt/rh/devtoolset-7/root/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Linux 内核有许多 头文件 具有 相同的名称 ,但位于不同的目录中。这些文件的确切路径非常重要。
出于这个原因,最好不要“glob”(使用终止 /**
)包含 Linux 内核的目录,而是编写 exact 的目录:
"includePath": [
# You could glob include directories for your module
"${workspaceFolder}/**",
# .. but do not glob Linux kernel ones
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/include",
# Do not glob arch-specific include directories for Linux kernel too
"/usr/src/kernels/3.10.0-1127.8.2.el7.x86_64/arch/x86/include"
],