赞
踩
xcode-select --install
这里是已经下载了
检验是否安装成功,终端输入
clang
如图所示是代表之前的command line tools安装 是安装成功的(Clang会不断更新的,更新位置系统更新中更新)
Download Visual Studio Code - Mac, Linux, Windows
(自定义创建位置,只要自己能记住安装位置即可)
文件后缀为.c是C文件,.cpp是C++文件
- #include<stdio.h>
- int main()
- {
- printf("Hello World\n");
- return 0;
- }
- #include <iostream>
- using namespace std;
- int main()
- {
- cout<<"Hello World!"<<endl;
- return 0;
- }
Debug Shortcut
(可直接复制,省事)
- {
- "version": "2.0.0",
- "tasks": [
- {
- "type": "cppbuild",
- "label": "C/C++: clang 生成活动文件",
- "command": "/usr/bin/clang",
- "args": [
- "-fcolor-diagnostics",
- "-fansi-escape-codes",
- "-g",
- "${file}",
- "-o",
- "${fileDirname}/${fileBasenameNoExtension}"
- ],
- "options": {
- "cwd": "${fileDirname}"
- },
- "problemMatcher": [
- "$gcc"
- ],
- "group": "build",
- "detail": "编译器: /usr/bin/clang"
- },
- {
- "type": "cppbuild",
- "label": "C/C++: clang++ 生成活动文件",
- "command": "/usr/bin/clang++",
- "args": [
- "-fcolor-diagnostics",
- "-fansi-escape-codes",
- "-g",
- "${file}",
- "-o",
- "${fileDirname}/${fileBasenameNoExtension}"
- ],
- "options": {
- "cwd": "${fileDirna me}"
- },
- "problemMatcher": [
- "$gcc"
- ],
- "group": "build",
- "detail": "编译器: /usr/bin/clang++"
- }
- ]
- }
- {
- "version": "0.2.0",
- "configurations": [
- {
- "name": "C调试",
- "type": "cppdbg",
- "request": "launch",
- "program": "${fileDirname}/${fileBasenameNoExtension}",
- "args": [],
- "stopAtEntry": false,
- "cwd": "${fileDirname}",
- "environment": [],
- "externalConsole": true,
- "MIMode": "lldb",
- "preLaunchTask": "C/C++: clang 生成活动文件"
- },
- {
- "name": "C++调试",
- "type": "cppdbg",
- "request": "launch",
- "program": "${fileDirname}/${fileBasenameNoExtension}",
- "args": [],
- "stopAtEntry": false,
- "cwd": "${fileDirname}",
- "environment": [],
- "externalConsole": true,
- "MIMode": "lldb",
- "postDebugTask": "C/C++: clang++ 生成活动文件"
- }
- ]
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。