log*_*ins 7 c visual-studio-code windows-subsystem-for-linux
我在使用适用于Windows的Linux子系统在Windows 10 build 17134上使用VS Code中的编辑器工作时遇到问题.我安装了C/C++扩展,可以使用此处文档中概述的launch.json信息运行我的应用程序.
在他们的文档在这里,微软概述了如何建立一个c_cpp_properties.json来解决这个问题,但目前还没有先进我很多.目前,我在"包含"行下面收到错误消息:
#include errors detected. Please update your includePath. IntelliSense features for this translation unit (C:\Users\Username\Source\c-lang\hello.c) will be provided by the Tag Parser.
cannot open source file "stdio.h"
我的c_cpp_properties.json:
{
"configurations": [
{
"name": "WSL",
"intelliSenseMode": "clang-x64",
"compilerPath": "/usr/bin/gcc",
"includePath": [
"${workspaceFolder}",
"/usr/include/"
],
"defines": [],
"browse": {
"path": [
"${workspaceFolder}",
"/usr/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "",
},
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
Run Code Online (Sandbox Code Playgroud)
理解了它得益于此在Github上的问题发表评论。
我接受了他们推荐的命令,并对其进行了编辑以使用C而不是C ++并在WSL中运行它:
gcc -v -E -x c -
Run Code Online (Sandbox Code Playgroud)
它列出了所有gcc都在寻找C库的地方。我复制了该列表,并将各个路径放入“ includePath”和“ path”数组中。这是我更新的c_cpp_properties.json文件:
{
"configurations": [
{
"name": "WSL",
"intelliSenseMode": "clang-x64",
"compilerPath": "/usr/bin/gcc",
"includePath": [
"${workspaceFolder}",
"/usr/include/x86_64-linux-gnu/5/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu/5/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include"
],
"defines": [],
"browse": {
"path": [
"${workspaceFolder}",
"/usr/include/x86_64-linux-gnu/5/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu/5/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
Run Code Online (Sandbox Code Playgroud)
希望这对某人有帮助。
| 归档时间: |
|
| 查看次数: |
4295 次 |
| 最近记录: |