Kel*_*uma 8 c include-path visual-studio-code
我正在 Ubuntu 18.04 上使用 C/C++ 扩展的 VSCode 进行工作。
我试图包含 gmodule.h,但它gmodule.h: No such file or directory
在主文件的第 2 行第 10 个字符上引发了错误。
因此,问题在于 gmodule.h 不在 /usr/include 中,而是在 /usr/include/glib-2.0 中。意识到这一点,我将此文件夹添加到 c_cpp_properties.json 中的 includePath 变量中。但是,它仍然会引发相同的错误。
当使用#include <glib-2.0/gmodule.h>
而不是 时#include <gmodule.h>
,它确实可以工作,但这只会将问题转移到 gmodule.h 本身,因为 glib-2.0 文件夹中的其他包含内容仍然无法在 gmodule.h 内部工作。
总而言之,问题是添加到 c_cpp_properties.json 中的 includePath 不会改变任何内容,我想知道如何使其工作,因为我想使用 gmodule。
c_cpp_properties.json:
{
"configurations": [
{
"name": "Linux",
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"includePath": [
"/usr/include/glib-2.0/*"
]
}
],
"version": 4
}
Run Code Online (Sandbox Code Playgroud)
现在我只是想包含 gmodule.h 并且还没有对它做任何事情,所以这是我的主文件:
#include <stdio.h>
#include <gmodule.h>
int main() {
printf("hai\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Dod*_*bit 14
c_cpp_properties.json
除其他外,IDE 中的智能感知解析的控件包括文件。IDE 和构建任务是独立的事物,因此在 VS Code 中独立配置和运行。
问题的解决方案是将包含路径添加到tasks.json
文件中,如下所示:
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"--include-directory=/usr/include/glib-2.0/"
],
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
18480 次 |
最近记录: |