我有点困惑,我无法使用MSVC在Windows上进行C开发设置Visual Studio Code . 网络上的所有人都说他们对设置和使用一切都很容易感到高兴,但我找不到任何简单的指南;他们中的大多数只是跳过设置部分,并显示一切有效,包括代码完成/智能感知和调试支持 .
我安装了Visual Studio 2015 Community Edition(包括调试工具等),Visual Studio Code和Microsoft的C扩展 .
接下来我需要做什么?
编辑:智能感知这些天开箱即用,这很棒 . 但是我的自动生成的tasks.json似乎没有用于构建的技巧,这就是它的样子:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"type": "process",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "always"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}
当我运行此任务时,它似乎无限运行,只输出到以下内容:
Executing task: msbuild /property:GenerateFullPaths=true /t:build <
有任何想法吗?
2 回答
我认为最简单的方法 - 打开visual studio 2017命令提示符控制台并从那里运行Visual Studio Code IDE,这样它就会选择所有必要的编译器环境变量
对于MSVC 2017版本:
您可以相应地更改驱动器名称和文件夹名称 .
2.在settings.json中更改shell设置:
这将启用集成终端中的cl命令 .
3.按ctrl`启用集成终端,输入cl / EHsc your_cpp_program.cpp进行编译 .