笔者发现自己是真的能够折腾…在Windows下选择了gcc/g++的C编译器,最近在搞Linux的时候又选择了clang/clang++。但是Windows下用GNU的软件都比较方便,只要下载一个MinGW installer就可以选择安装各种GNU的单品了,但是在Linux下配置clang/clang++就显得有些麻烦了。
clang及llvm的下载:https://www.cnblogs.com/focus-lei/p/9640574.html
vscode的下载:vscode官网(自己百度)
(注: vscode需要各种配置文件,但是官网上的都是针对单个文件的。一个比较推荐的方法就是——先上官网查看各种配置文件如何生成,再到blogs中查找可行的配置)
我个人的launch.json配置(debug还是选择了gdb,因为找不到lldb,逃)
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"cwd": "${workspaceFolder}",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "Build with Clang",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"stopAtEntry": false,
"launchCompleteCommand": "exec-run",
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
}
}
],
"configurations1": [
{
"name": " Launch C",
"type": "cppdbg",
"request": "launch",
"program": "{fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"preLaunchTask1": "compile",
"environment": [],
"externalConsole": false,
"MIMode": "gcc",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
我的task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build with Clang",
"type": "shell",
"command": "clang++",
"args": [
"-std=c++17",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.out"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
注意clang专门用于c,clang++专门用于c++,这个两个不要弄混了。
(把这个放在最后,是因为我认为配置好环境,无需了解各个程序背后的原理,组成啥的,只要能跑就行。但是你用过的东西,不深入了解也不行,所以就有了这一模块)
编译器架构:https://www.cnblogs.com/opangle/archive/2012/07/23/2605278.html(还是上面一篇blog)
深入了解llvm系列:https://blog.csdn.net/xfxyy_sxfancy/article/details/49686523
这篇文章个人还是不太满意,有空了再来修补一下
还要做的事情: