当前位置:网站首页>VSCode使用总结
VSCode使用总结
2022-08-09 02:35:00 【lp_oreo】
1. VSCode配置C++环境
1.1 配置c_cpp_properties.json文件
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:/softwares/opencv/build/include/" // 配置opencv环境
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
//此处是编译器路径,以后可直接在此修改
"compilerPath": "D:/MinGW/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}1.2 配置launch.json文件
launch.json文件主要是配置编译器的参数。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "D:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe 生成活动文件"
}
]
}1.3 配置settings.json文件
{
"files.associations": {
"vector": "cpp",
"xstring": "cpp"
}
}1.4 配置tasks.json文件
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "D:\\MinGW\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}2.设置C++的使用版本

3. 如何include自己的头文件
在编写工程项目的时候,往往需要include自己写的头文件,不过这在vscode中如何设置呢,使的IDE可以找到我们自己的头文件并正确执行呢?主要有两步,第一步修改c_cpp_properties.json文件的includePath参数;第二步修改tasks.json文件中的args参数。
下图是提供的参考工程目录,在include文件中保存着工程的所有头文件,在src中则保存着所有的cpp文件。

3.1 配置c_cpp_properties.json文件
需要将自己的头文件目录添加到includePath参数中,使得编译器能够找到我们所提供的头文件。如下图所示,workspaceFolder表示当前工程的头文件目录。

3.2 配置tasks.json文件
添加-I参数,用于给编译器提供自定义的头文件及其实现文件。如下图所示:

3.3 参考文献
(1)Windows下用VScode编写C++程序如何添加并应用自定义头文件_Penguuuuiiiiiiin的博客-CSDN博客_vscode写c++头文件
边栏推荐
- 微信公众号跳转小程序 wx-open-launch-weapp (最全指南及坑)
- php过滤特殊字符(仅保留中文、字母、数字、下划线)
- 基于JMF视频聊天
- UsernameAuthenticationFilter授权成功后调用AuthenticationSuccessHandler时的解析
- C#计算SHA1加密和base64编码
- The last exam before the NPDP revision!caution
- 炫酷-轮播图-走马灯
- JS 实现千分位分隔符
- A40i gxl3680 ts_print报错:tslib: Selected device is not a touchscreen (must support ABS and KEY event
- OJ:L2-012 关于堆的判断
猜你喜欢

10.1-----19. Delete the Nth node from the bottom of the linked list

MT4/MQL4 Getting Started to Mastering EA Tutorial Lesson 1 - MQL Language Common Functions (1) OrderSend() Function
![[ANT]apache ant 安装说明](/img/65/9ed0052d0f950b4dad0fc3430b7271.png)
[ANT]apache ant 安装说明

电磁辐射安全标准及检测方法

接口的安全性测试,应该从哪些方面入手?

Likou Brush Question Record 8.1-----206. Reverse linked list

点击div内部默认文本被选中

多态 polymorphism

【剑指offer65】不适用加减乘除做加法

使网络安全威胁风险更高和成本更高的五个趋势
随机推荐
Programmer's Daily Life | Daily Fun
最新工业界推荐系统数据集-召回排序模型原理、结构及代码实战整理分享
攀爬倒影发光方块
Which is the best increased whole life insurance?Is it really safe?
Analysis of when AuthenticationSuccessHandler is called after UsernameAuthenticationFilter is authorized successfully
JS 截取数组的最后几个元素
etcd实现大规模服务治理应用实战
How to install yii2
NPDP改版前最后一次考试!请注意
How to play knowledge graph in recommender system
“蔚来杯“2022牛客暑期多校训练营7,签到题CFGJ
Postman接口测试【官网】最新版本 安装及使用入门教程
Etcd realize large-scale application service management of actual combat
如何最大限度地减少企业受到供应链攻击的风险
企业面临的五大数据安全挑战
C#计算两个时间相差多少天、时、分、秒
继承 Inheritance
数字 05 verilog&vivado2018.2零散笔记
1261. 在受污染的二叉树中查找元素
【Jenkins 学习笔记】玩转持续集成与持续交付