Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code other位于列表底部_Visual Studio Code_Vscode Tasks - Fatal编程技术网

Visual studio code other位于列表底部

Visual studio code other位于列表底部,visual-studio-code,vscode-tasks,Visual Studio Code,Vscode Tasks,在同一文件夹中创建名为build.bat的批处理文件,并在文件正文中包含以下代码: @echo关闭 调用“C:\ProgramFiles(x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat”x64 set compilerflags=/Od/Zi/EHsc 设置linkerflags=/OUT:hello.exe cl.exe%compilerflags%hello.cpp/link%linkerflags% 按如下所示编辑task.json

在同一文件夹中创建名为build.bat的批处理文件,并在文件正文中包含以下代码:

@echo关闭
调用“C:\ProgramFiles(x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat”x64
set compilerflags=/Od/Zi/EHsc
设置linkerflags=/OUT:hello.exe
cl.exe%compilerflags%hello.cpp/link%linkerflags%
  • 按如下所示编辑task.json文件并保存它:
  • {
    //看https://go.microsoft.com/fwlink/?LinkId=733558
    //有关tasks.json格式的文档
    “版本”:“0.1.0”,
    “命令”:“build.bat”,
    “isShellCommand”:正确,
    //“args”:[“Hello World”],
    “showOutput”:“始终”
    }
    
  • 点击(Ctrl+Shift+B)运行生成任务。这将为项目创建.obj.exe文件

  • 要调试项目,请点击F5并选择C++(Windows)

  • launch.json文件中,编辑以下行并保存该文件:

  • “程序”:“${workspaceRoot}/hello.exe”,
    
  • 按F5

  • 新2.0.0 tasks.json版本的makefile任务示例

    在下面的片段中,我希望这些评论会有用

    {
    “版本”:“2.0.0”,
    “任务”:[
    {
    “标签”:“,
    “类型”:“外壳”,
    “命令”:“制作”,
    //如果生成文件不在项目根${workspaceRoot}目录中,请使用options.cwd属性
    “选择”:{
    “cwd”:“${workspaceRoot}/”
    },
    //在不提示选择任务的情况下启动生成,否则使用“组”:“生成”
    “集团”:{
    “种类”:“建造”,
    “isDefault”:正确
    },
    “介绍”:{
    “回声”:没错,
    “透露”:“始终”,
    “焦点”:错误,
    “面板”:“共享”
    },
    //arg传递示例:在这种情况下执行makequiet=0
    “args”:[“安静=0”],
    //使用无标准编译问题匹配器。
    “问题匹配者”:{
    “所有者”:“cpp”,
    “文件位置”:[“绝对”],
    “模式”:{
    “regexp:“^(.*):(\\d+):(\\d+):\\s+(警告|错误):\\s+(.*)$”,
    “文件”:1,
    "线":2,,
    "栏目":3,,
    “严重性”:4,
    “信息”:5
    }
    }
    }
    ]
    }
    
    您可以参考此最新的要点,其中包含Visual Studio代码的版本
    2.0.0
    任务


    您可以轻松编译和运行每个文件,而无需更新任务。它是通用的,还可以打开终端以输入条目。

    以下是我如何为C配置VS++


    确保将适当的路径更改为安装MinGW的位置

    launch.json

    {
    “版本”:“0.2.0”,
    “配置”:[
    {
    “名称”:“C++启动(GDB)”,
    “类型”:“cppdbg”,
    “请求”:“启动”,
    “目标体系结构”:“x86”,
    “程序”:“${workspaceRoot}\\\${fileBasename}.exe”,
    “miDebuggerPath”:“C:\\mingw-w64\\bin\\gdb.exe”,
    “args”:[],
    “stopAtEntry”:false,
    “cwd”:“${workspaceRoot}”,
    “外部控制台”:正确,
    “预启动任务”:“g++”                    
    }
    ]
    }
    
    tasks.json

    
    {
    “版本”:“0.1.0”,
    “命令”:“g++”,
    “args”:[“-g”、“-std=c++11”、“${file}”、“-o”、“${workspaceRoot}\\\\${fileBasename}.exe”],
    “问题匹配者”:{
    “所有者”:“cpp”,
    “文件位置”:[“相对”,“${workspaceRoot}],
    “模式”:{
    “regexp:“^(.*):(\\d+):(\\d+):\\s+(警告|错误):\\s+(.*)$”,
    “文件”:1,
    "线":2,,
    "栏目":3,,
    “严重性”:4,
    “信息”:5
    }
    }
    }
    
    c_cpp_properties.json

    {
    “配置”:[
    {
    “名称”:“Win32”,
    “包含路径”:[
    “${workspaceRoot}”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++/x86_64-w64-mingw32”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++/backward”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++/tr1”,
    “C:/mingw-w64/x86_64-w64-mingw32/include”
    ],
    “定义”:[
    “_调试”,
    “UNICODE”,
    “\uuuu GNUC\uuuuuu=6”,
    “\uuuuCDECL=\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
    ],
    “intelliSenseMode”:“msvc-x64”,
    “浏览”:{
    “路径”:[
    “${workspaceRoot}”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++/x86_64-w64-mingw32”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++/backward”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include”,
    “C:/mingw-w64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/C++/tr1”,
    “C:/mingw-w64/x86_64-w64-mingw32/include”
    ]
    },
    “limitSymbolsToIncludedHeaders”:正确,
    “数据库文件名”:”
    }
    ],
    “版本”:3
    }
    
    参考:

  • <
    ext install cpptools