当前位置: 首页 > news >正文

vscode 支持c,c++编译调试方法

概述:tasks.jason   launch.json settings.json一定要有,没有就别想跑。还有就是c 和c++配置有区别,切记,下文有说

1.安装扩展插件。

2.安装编译器,gcc.我用的是x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z ,直接解压缩到你喜欢的目录,然后在环境变量里面添加即可。

3.找个目录,创建一个c或者c++文件。

4.将目录打开,可以选择在c/c++文件目录下右键,vscode打开即可。然后可以在目录下看到.vscode文件夹,下面就是一些脚本,可以改。

5.c和c++不太一样。在tasks.json 里面(如果没有,自己创建,一共三个文件,在第7点里面)。

6.碰到的问题点。如果细致一点,按下操作,如果不想麻烦,直接在第7点,文章末尾三个文件直接创建和我一样的就行了。

然后拷贝我的tasks目录进去就好了。

7.我的三个目录的代码是

tasks.json

{"version": "2.0.0","tasks": [{"type": "shell","label": "compile","command": "gcc","args": ["-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true}}]
}

settings.json

{"C_Cpp_Runner.cCompilerPath": "gcc","C_Cpp_Runner.cppCompilerPath": "g++","C_Cpp_Runner.debuggerPath": "gdb","C_Cpp_Runner.cStandard": "","C_Cpp_Runner.cppStandard": "","C_Cpp_Runner.msvcBatchPath": "","C_Cpp_Runner.useMsvc": false,"C_Cpp_Runner.warnings": ["-Wall","-Wextra","-Wpedantic","-Wshadow","-Wformat=2","-Wcast-align","-Wconversion","-Wsign-conversion","-Wnull-dereference"],"C_Cpp_Runner.msvcWarnings": ["/W4","/permissive-","/w14242","/w14287","/w14296","/w14311","/w14826","/w44062","/w44242","/w14905","/w14906","/w14263","/w44265","/w14928"],"C_Cpp_Runner.enableWarnings": true,"C_Cpp_Runner.warningsAsError": false,"C_Cpp_Runner.compilerArgs": [],"C_Cpp_Runner.linkerArgs": [],"C_Cpp_Runner.includePaths": [],"C_Cpp_Runner.includeSearch": ["*","**/*"],"C_Cpp_Runner.excludeSearch": ["**/build","**/build/**","**/.*","**/.*/**","**/.vscode","**/.vscode/**"],"C_Cpp_Runner.useAddressSanitizer": false,"C_Cpp_Runner.useUndefinedSanitizer": false,"C_Cpp_Runner.useLeakSanitizer": false,"C_Cpp_Runner.showCompilationTime": false,"C_Cpp_Runner.useLinkTimeOptimization": false,"C_Cpp_Runner.msvcSecureNoWarnings": false
}

launch.json

{"version": "0.2.0","configurations": [{"name": "C/C++","type": "cppdbg","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "gdb.exe","preLaunchTask": "compile","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]},{"name": "C/C++ Runner: Debug Session","type": "cppdbg","request": "launch","args": [],"stopAtEntry": false,"externalConsole": true,"cwd": "d:/test","program": "d:/test/build/Debug/outDebug","MIMode": "gdb","miDebuggerPath": "gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}]
}

8. 参数解释

http://www.lryc.cn/news/269533.html

相关文章:

  • MyBatis的缓存!!!!
  • ToB还是ToC?工业级与消费级AR眼镜都能干什么?
  • 设计模式-Java版本
  • 数据库中如何修改和删除字段
  • 在 Golang 应用程序中管理多个数据库
  • 理解开源协议GPL、MIT、BSD、Apache License
  • Talk | 北京大学博士生汪海洋:通向3D感知大模型的前置方案
  • 【C语言数组传参】规则详解
  • 【Linux】Ubuntu22.04版本下实现gcc版本的快速切换
  • 使用Node Exporter采集主机数据
  • Django 文件上传(十二)
  • k8s的陈述式资源管理
  • electron-builder 打包exe后白屏
  • mvvm,vue双向数据绑定的原理
  • 【Java中序列化的原理是什么(解析)】
  • 冠赢互娱基于 OpenKrusieGame 实现游戏云原生架构升级
  • Mybatis 动态 SQL - trim, where, set
  • 大模型系列:OpenAI使用技巧_使用OpenAI进行K-means聚类
  • 共享单车之数据分析
  • Spring的Bean你了解吗
  • MongoDB聚合:$merge 阶段(1)
  • 2. 云原生实战之kubesphere搭建
  • main参数传递、反汇编、汇编混合编程
  • 前后端分离nodejs+vue医院预约挂号系统6nrhh
  • 在pytorch中,读取GPU上张量的数值 (数据从GPU到CPU) 的几种常用方法
  • 【mysql】—— 表的内连和外连
  • VSCode远程开发配置
  • 复数值神经网络可能是深度学习的未来
  • 【C语言】数据结构——排序二(快排)
  • 企业私有云容器化架构