# my-cpp **Repository Path**: sn_yang/my-cpp ## Basic Information - **Project Name**: my-cpp - **Description**: 一个C++初学者的项目 - **Primary Language**: C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-01 - **Last Updated**: 2025-02-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 我的 C/C++ 项目 ## 特性 - [x] 编译器 - [x] 支持 `LLVM\Clang` (默认) - [x] 支持 `MinGW-x64` (可切换) - [x] 支持 `MSVC` (可切换) - [x] 支持 lint - [x] 支持 build/debug - [ ] 支持 cmake - [ ] 提供 c 基本语法代码示例 - [ ] 提供 c++ 基本语法代码示例 - [ ] 提供 文件操作帮助类 - [ ] 提供 算法 ## 开发环境 ### 准备 需要安装以下工具 - git - vscode - vscode 扩展 - C/C++ Extension Pack ### 如果需要使用 LLVM\Clang #### 准备环境 - 下载 `LLVM`。 [下载: 官方网站(慢)](https://releases.llvm.org/) [下载: 清华 LLVM 镜像](https://mirror.tuna.tsinghua.edu.cn/github-release/llvm/llvm-project) Winddows 环境选择 `LLVM-xx.xx.xx-win64.exe` - 安装 `LLVM` - 查看版本 ```sh clang --version ``` ### 如果需要使用 MinGW-x64 #### 准备环境 - 下载 `MinGW`。 [下载: 清华 msys2 镜像](https://mirror.tuna.tsinghua.edu.cn/msys2/distrib/) - 运行 `msys2` - 在 `MSYS` 中,安装 `mingw-w64` ```sh pacman -S --needed base-devel mingw-w64-x86_64-toolchain ``` - 设置系统变量 `PATH` 增加 `C:\msys64\mingw64\bin` 到系统变量`PATH`中。 - 检测版本 ```sh gcc --version g++ --version gdb --version ``` ### 如果需要使用 MSVC #### 准备环境 - 下载 Visual Studio。[下载](https://visualstudio.microsoft.com/zh-hans/downloads/) Visual Studio 社区版是免费的。 - 安装下载的 VisualStudioSetup.exe 这个安装的是 Visual Studio Installer - 运行 Visual Studio Installer - 安装 Visual Studio 生成工具 - 选择 `使用C++的桌面开发` - 选择: MSVC XX - 选择: Windows XX SDK - 选择: 用于 Windows 的 C++ CMake 工具 - 安装 - 配置 复制 `.vscode\c_cpp_properties.msvc.json` 到 `.vscode\c_cpp_properties.json` 复制 `.vscode\launch.msvc.json` 到 `.vscode\launch.json` 复制 `.vscode\tasks.msvc.json` 到 `.vscode\tasks.json` #### 运行程序 - 打开 vscode - 先打开 MSVC 运行环境 `Developer Command Prompt for VS 2019` - 在命令行中,进入本项目 ```cmd cd code . ``` - 编译: `F1` -> `Tasks: Run Task` -> `C/C++: cl.exe 生成活动文件` - 运行方法 1: `Run and Debug` -> `MSVC: Launch` - 运行方法 2: 文件右上角的 `Run C/C++ File` - 运行方法 3: 文件右上角的 `Debug C/C++ File` ### C++ 代码风格 - [C++ 谷歌风格指南(中文版) - ReadTheDocs 托管地址](https://zh-google-styleguide.readthedocs.io/en/latest/) - [C++ 谷歌风格指南(中文版) - GitHub 托管地址 zh-google-styleguide](https://github.com/zh-google-styleguide/zh-google-styleguide) - [C++ 谷歌风格指南(中文版) - 离线文档下载地址](https://github.com/zh-google-styleguide/zh-google-styleguide/releases) - [C++ Google Style Guide (English)](https://google.github.io/styleguide/cppguide.html) ### 代码自动格式化 - 扩展: `C/C++`(默认) 支持 `clangFormat` (默认)和 `vcFormat`。 该项目配置为 `Google`。 可通过 `.clang_format` 文件做自定义。 - 扩展: `Clang-Tidy`(notskm.clang-tidy) 使用 Clang-Tidy 工具。 - 扩展: `Clang-Format`(xaver.clang-format) C\C++ 代码格式化扩展。 - 扩展: `C/C++ Advanced Lint for VS Code` 支持多种 lint 工具。 ## C\C++ 学习指南 - [C\C++ 语言标准](https://en.cppreference.com) - [C 语言教程 | 菜鸟教程](https://www.runoob.com/cprogramming/c-tutorial.html) - [C++ 语言教程 | 菜鸟教程](https://www.runoob.com/cplusplus/cpp-tutorial.html)