两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 |
public:it:cplusplus [2022/05/05 19:11] – [Articles] oakfire | public:it:cplusplus [2025/02/17 14:59] (当前版本) – [Articles] oakfire |
---|
* [[https://github.com/google/sanitizers/wiki/AddressSanitizer|AddressSanitizer]] 内存错误检测:-o | * [[https://github.com/google/sanitizers/wiki/AddressSanitizer|AddressSanitizer]] 内存错误检测:-o |
* Meson 构建系统打开 ASAN 的方式:[[https://mesonbuild.com/Builtin-options.html#base-options|设置 b_sanitize]] | * Meson 构建系统打开 ASAN 的方式:[[https://mesonbuild.com/Builtin-options.html#base-options|设置 b_sanitize]] |
| * [[https://agraphicsguynotes.com/posts/fiber_in_cpp_understanding_the_basics/|Fiber in C++: 纤程的原理与实现]] |
| * [[https://learnmoderncpp.com/|Learn Modern C++]] |
| * [[https://blogs.gentoo.org/mgorny/2024/09/23/overview-of-cross-architecture-portability-problems/|C的移植性问题,参考]] |
| |
===== Syntax ===== | ===== Syntax ===== |
* 正则 std::regex | * 正则 std::regex |
* 随机数相关 ''<random>'' | * 随机数相关 ''<random>'' |
| * 关于 shared_ptr 的线程安全:[[https://www.boost.org/doc/libs/1_73_0/libs/smart_ptr/doc/html/smart_ptr.html#shared_ptr_thread_safety|shared_ptr_thread_safety]] |
* c++ 14 新增 std::make_unique, std::shared_timed_mutex, std::shared_lock, std::integer_sequence, std::exchange, std::quoted | * c++ 14 新增 std::make_unique, std::shared_timed_mutex, std::shared_lock, std::integer_sequence, std::exchange, std::quoted |
* c++ 17 新增 std::variant, std::optional, std::any, std::apply, std::string_view, std::shared_mutex | * c++ 17 新增 std::variant, std::optional, std::any, std::apply, std::string_view, |
* 新增文件操作相关 std::filesystem | * 读写锁 std::shared_mutex |
| * 文件操作相关 std::filesystem |
* c++ 20 新增 std::format, 基于[[https://docs.python.org/3/library/string.html#formatspec|python格式化规范]] | * c++ 20 新增 std::format, 基于[[https://docs.python.org/3/library/string.html#formatspec|python格式化规范]] |
* 可中断线程 std::jthread, std::stop_toke | * 可中断线程 std::jthread, std::stop_token |
| * 并发控制 std::barrier, std::latch |
| * 协程关键字 co_await, co_yield, co_return |
| * 操作 std::ranges, std::views |
* 原子引用 std::atomic_ref | * 原子引用 std::atomic_ref |
* 数学常数 std::numbers | * 数学常数 std::numbers |
* For a native linker on an ELF system, if the file ''/etc/ld.so.conf'' exists, the list of directories found in that file. | * For a native linker on an ELF system, if the file ''/etc/ld.so.conf'' exists, the list of directories found in that file. |
* 由上,如果不想混淆系统lib, 程序可自行用 ''LD_LIBRARY_PATH'' 环境变量指定自己的lib目录。 | * 由上,如果不想混淆系统lib, 程序可自行用 ''LD_LIBRARY_PATH'' 环境变量指定自己的lib目录。 |
| ==== › Tips ==== |
| * 禁用异常的编译选项:''-fno-exceptions'' |
| * 有返回值声明的函数末尾如果没有返回, gcc 7.5 版本编译时会默认加个 return 0, 但之后的版本应该是和 clang 一样不加了。c++11 标准,有返回值声明的函数末尾如果没有返回,将出现未定义行为。所以按理这个情况编译器应该报错,但 gcc 编译只报了 warning , 而运行时没有返回值导致的 crash 栈信息都很奇怪不好查。 所以gcc7.5之后的编译参数都得加上 ''-Werror=return-type'' ,这样没有返回值时编译期可以报error,好规避问题。 |
| * gcc/g++ 优化级别详细查看:''gcc -Q --help=optimizers -O1'' |
| |
| |
===== C++资源与工具 ===== | ===== C++资源与工具 ===== |
* [[https://github.com/fffaraz/awesome-cpp|awesome-cpp]] | * [[https://github.com/fffaraz/awesome-cpp|awesome-cpp]] |
==== › Build System ==== | ==== › Build System ==== |
* [[.:cmake]] - Cross-platform free and open-source software for managing the build process of software using a compiler-independent method. [BSD] | * [[.:cmake]] - Cross-platform free and open-source software for managing the build process of software using a compiler-independent method. [BSD] |
* [[https://ninja-build.org/|Ninja]] - Ninja is a small build system with a focus on speed.[Apache 2.0] | * [[https://ninja-build.org/|Ninja]] - Ninja is a small build system with a focus on speed.[Apache 2.0], 对标Make, 专注速度 |
* autotools | * autotools |
* [[gyp]] | * [[gyp]] |
=== 包管理 === | * [[https://mesonbuild.com/|meson]] - Meson is an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible. (python) |
| ==== › 包管理 ==== |
* [[https://github.com/microsoft/vcpkg|Vcpkg]] - C++ library manager for Windows, Linux, and MacOS. [MIT] | * [[https://github.com/microsoft/vcpkg|Vcpkg]] - C++ library manager for Windows, Linux, and MacOS. [MIT] |
* vcpkg 安装的库默认都可以向后兼容,更新方法为直接git pull 最新vcpkg然后 vcpkg update/upgrade, 如果为了协作与稳定,可以指定 git checkout vcpkg 的某个tag, 来保证彼此库版本一致。 | * vcpkg 安装的库默认都可以向后兼容,更新方法为直接git pull 最新vcpkg然后 vcpkg update/upgrade, 如果为了协作与稳定,可以指定 git checkout vcpkg 的某个tag, 来保证彼此库版本一致。 |
* [[http://valgrind.org/|valgrind]] - A tool for memory debugging, memory leak detection, and profiling. | * [[http://valgrind.org/|valgrind]] - A tool for memory debugging, memory leak detection, and profiling. |
* [[https://github.com/nlohmann/json|nlohmann-json]] - JSON for Modern C++. [MIT] | * [[https://github.com/nlohmann/json|nlohmann-json]] - JSON for Modern C++. [MIT] |
| * [[https://github.com/sogou/workflow|Sogou C++ Workflow]] - This is an enterprise-level programming engine in light and elegant design which can satisfy most C++ back-end development requirements.[Apache-2.0] |
| * [[https://github.com/yhirose/cpp-httplib|cpp-httplib]] - A C++11 single-file header-only cross platform HTTP/HTTPS library.[MIT] |
| |
| |