manual-visual-studio-code
Version:
Visual Studio Code 手册
399 lines (188 loc) • 19.5 kB
HTML
<html lang="zh-hans" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>C / C++ · Visual Studio Code</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<meta name="author" content="Kuriv Vesti">
<link rel="stylesheet" href="../../gitbook/style.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-lightbox/css/lightbox.min.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism-okaidia.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="prev" href="../编译系统.html" />
<link rel="shortcut icon" href='../../favicon.ico' type="image/x-icon">
<link rel="bookmark" href='../../favicon.ico' type="image/x-icon">
<link rel="apple-touch-icon" href='../../favicon.png'>
<link rel="apple-touch-icon" sizes="120x120" href="../../favicon-120x120.png">
<link rel="apple-touch-icon" sizes="180x180" href="../../favicon-180x180.png">
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="输入并搜索" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="../../">
<a href="../../">
Visual Studio Code
</a>
<ul class="articles">
<li class="chapter " data-level="1.1.1" data-path="../插件清单.html">
<a href="../插件清单.html">
插件清单
</a>
<ul class="articles">
<li class="chapter " data-level="1.1.1.1" data-path="../插件清单/Language Pack.html">
<a href="../插件清单/Language Pack.html">
Language Pack
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.1.2" data-path="../编译系统.html">
<a href="../编译系统.html">
编译系统
</a>
<ul class="articles">
<li class="chapter active" data-level="1.1.2.1" data-path="C.html">
<a href="C.html">
C / C++
</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
本书使用 GitBook 发布
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../.." >C / C++</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="c--c">C / C++</h1>
<p>将 C 添加至环境变量,打开应用商店,输入 <code>C/C++</code> 并安装,安装完成后打开工作区中的 C 文件或 C++ 文件,使用快捷键 <code>F5</code> ,然后选择 <code>C++ (GDB/LLDB)</code> ,选择 <code>gcc.exe build and debug active file</code> ,之后会在当前工作区中的 <code>.vscode</code> 文件夹中自动生成 <code>launch.json</code> 配置文件。</p>
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span>
<span class="token property">"version"</span><span class="token operator">:</span> <span class="token string">"0.2.0"</span><span class="token punctuation">,</span>
<span class="token property">"configurations"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"gcc.exe build and debug active file"</span><span class="token punctuation">,</span>
<span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"cppdbg"</span><span class="token punctuation">,</span>
<span class="token property">"request"</span><span class="token operator">:</span> <span class="token string">"launch"</span><span class="token punctuation">,</span>
<span class="token property">"program"</span><span class="token operator">:</span> <span class="token string">"${fileDirname}\\${fileBasenameNoExtension}.exe"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"stopAtEntry"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"cwd"</span><span class="token operator">:</span> <span class="token string">"${workspaceFolder}"</span><span class="token punctuation">,</span>
<span class="token property">"environment"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"externalConsole"</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token property">"MIMode"</span><span class="token operator">:</span> <span class="token string">"gdb"</span><span class="token punctuation">,</span>
<span class="token property">"miDebuggerPath"</span><span class="token operator">:</span> <span class="token string">"当前环境中 gdb.exe 的执行路径"</span><span class="token punctuation">,</span>
<span class="token property">"setupCommands"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"description"</span><span class="token operator">:</span> <span class="token string">"为 gdb 启用整齐打印"</span><span class="token punctuation">,</span>
<span class="token property">"text"</span><span class="token operator">:</span> <span class="token string">"-enable-pretty-printing"</span><span class="token punctuation">,</span>
<span class="token property">"ignoreFailures"</span><span class="token operator">:</span> <span class="token boolean">true</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"preLaunchTask"</span><span class="token operator">:</span> <span class="token string">"gcc.exe build active file"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre>
<p>编辑好 <code>launch.json</code> 配置文件后保存,返回到工作区中的 C 文件或 C++ 文件,重新使用快捷键 <code>F5</code> , Visual Studio Code 会弹出错误窗口并提示 <code>找不到任务"gcc.exe build active file"</code> ,选择 <code>配置任务</code> ,选择 <code>C/C++: gcc.exe build active file</code> ,会在当前工作区中的 <code>.vscode</code> 文件夹中自动生成 <code>tasks.json</code> 配置文件。</p>
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span>
<span class="token property">"version"</span><span class="token operator">:</span> <span class="token string">"2.0.0"</span><span class="token punctuation">,</span>
<span class="token property">"tasks"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"shell"</span><span class="token punctuation">,</span>
<span class="token property">"label"</span><span class="token operator">:</span> <span class="token string">"gcc.exe build active file"</span><span class="token punctuation">,</span>
<span class="token property">"command"</span><span class="token operator">:</span> <span class="token string">"当前环境中 gcc.exe 的执行路径"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token string">"-g"</span><span class="token punctuation">,</span>
<span class="token string">"${file}"</span><span class="token punctuation">,</span>
<span class="token string">"-o"</span><span class="token punctuation">,</span>
<span class="token string">"${fileDirname}\\${fileBasenameNoExtension}.exe"</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"options"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"cwd"</span><span class="token operator">:</span> <span class="token string">"当前环境中 C 的执行路径"</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"problemMatcher"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token string">"$gcc"</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"group"</span><span class="token operator">:</span> <span class="token string">"build"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre>
<p>编辑好 <code>tasks.json</code> 配置文件后保存,再次返回到工作区中的 C 文件或 C++ 文件,此时再次使用快捷键 <code>F5</code> 即可看到运行结果。</p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../编译系统.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 编译系统">
<i class="fa fa-angle-left"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"C / C++","level":"1.1.2.1","depth":3,"previous":{"title":"编译系统","level":"1.1.2","depth":2,"path":"docs/编译系统.md","ref":"docs/编译系统.md","articles":[{"title":"C / C++","level":"1.1.2.1","depth":3,"path":"docs/编译系统/C.md","ref":"docs/编译系统/C.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["back-to-top-button","chapter-fold","favicon","hide-element","lightbox","-highlight","prism","-lunr","-search","search-pro","splitter","livereload"],"root":"","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"prism":{"css":["prismjs/themes/prism-okaidia.css"]},"livereload":{},"splitter":{},"search-pro":{},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"favicon":{"shortcut":"favicon.ico","bookmark":"favicon.ico","appleTouch":"favicon.png","appleTouchMore":{"120x120":"favicon-120x120.png","180x180":"favicon-180x180.png"}},"lightbox":{"jquery":true,"sameUuid":false},"back-to-top-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Kuriv Vesti","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"isbn":"","variables":{},"title":"Visual Studio Code","language":"zh-hans","gitbook":">=3.0.0","description":"Visual Studio Code 手册","direction":"ltr"},"file":{"path":"docs/编译系统/C.md","mtime":"2020-02-20T11:23:31.968Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-02-20T11:26:08.073Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.js"></script>
<script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
<script src="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
<script src="../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
<script src="../../gitbook/gitbook-plugin-lightbox/js/lightbox.min.js"></script>
<script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
<script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
<script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
<script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>