两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 |
public:it:cplusplus [2023/10/13 09:01] – [› Tips] oakfire | public:it:cplusplus [2024/03/15 11:22] (当前版本) – [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++]] |
| |
===== Syntax ===== | ===== Syntax ===== |
* 禁用异常的编译选项:''-fno-exceptions'' | * 禁用异常的编译选项:''-fno-exceptions'' |
* 有返回值声明的函数末尾如果没有返回, gcc 7.5 版本编译时会默认加个 return 0, 但之后的版本应该是和 clang 一样不加了。c++11 标准,有返回值声明的函数末尾如果没有返回,将出现未定义行为。所以按理这个情况编译器应该报错,但 gcc 编译只报了 warning , 而运行时没有返回值导致的 crash 栈信息都很奇怪不好查。 所以gcc7.5之后的编译参数都得加上 ''-Werror=return-type'' ,这样没有返回值时编译期可以报error,好规避问题。 | * 有返回值声明的函数末尾如果没有返回, gcc 7.5 版本编译时会默认加个 return 0, 但之后的版本应该是和 clang 一样不加了。c++11 标准,有返回值声明的函数末尾如果没有返回,将出现未定义行为。所以按理这个情况编译器应该报错,但 gcc 编译只报了 warning , 而运行时没有返回值导致的 crash 栈信息都很奇怪不好查。 所以gcc7.5之后的编译参数都得加上 ''-Werror=return-type'' ,这样没有返回值时编译期可以报error,好规避问题。 |
| * gcc/g++ 优化级别详细查看:''gcc -Q --help=optimizers -O1'' |
| |
| |
* [[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] |
| |
| |