Back To Basics: The Rule of FiveAgenda ● Background ● Core Guidelines ● What is the Rule of Five ● Compiler provided functions ● What is the Rule of Zero 3Copyright © 2023 Andre Kostur C++ is a net> C++ Core Guidelines 6Copyright © 2023 Andre Kostur Guideline C.21 is “The Rule of Five” 7Copyright © 2023 Andre Kostur Simple String 8Copyright © 2023 Andre nullptr; return *this; } // … char * data_; }; 19Copyright © 2023 Andre Kostur The Rule of Five C.21: “If you define or =delete any copy, move, or destructor function, define or =delete 0 码力 | 42 页 | 623.10 KB | 6 月前3
Cache-Friendly Design in Robot Path Planning158 wr) ==131579== LLd misses: 3,336,167 ( 2,266,653 rd + 1,069,514 wr) ==131579== D1 miss rate: 7.9% ( 9.6% + 0.7% ) ==131579== LLd miss rate: 158 wr) ==131579== LLd misses: 3,336,167 ( 2,266,653 rd + 1,069,514 wr) ==131579== D1 miss rate: 7.9% ( 9.6% + 0.7% ) ==131579== LLd miss rate: ==131579== LLd misses: 3,336,167 ( 2,266,653 rd + 1,069,514 wr) 12 ==131579== D1 miss rate: 7.9% ( 9.6% + 0.7% ) 13 ==131579== LLd miss rate:0 码力 | 216 页 | 10.68 MB | 6 月前3
Back to Basics: The structure of a Programwrite • The phases of translation • Declarations, definitions, and linkage • The one-definition rule (ODR) • Storage duration • ABIs and name-mangling • Linking and loading CppCon 2020 - The Structure use Build Tools Source Code Tools Dependency Packages Dependency Tools ld, ld.bfd, ld.gold, lld, link.exe, …Copyright © 2020 Bob Steagall K E W B C O M P U T I N G C++ Programming Ecosystem – Building and z have no linkageCopyright © 2020 Bob Steagall K E W B C O M P U T I N G The One-Definition Rule (ODR) • A given translation unit can contain at most one definition of any: • variable • function0 码力 | 64 页 | 390.34 KB | 6 月前3
Shared Librarieswith – • --no-allow-shlib-undefined (on the exe) • Operates recursively on ld, not on gold/lld. • -z defs (on the shlib) • --no-undefined (on the shlib) 19 bar foo exe lib1 lib2 lib3 lib4 Mach-O and PE/COFF have many problems but this may be a place where they got right.” Fangrui Song, LLD maintainer https://maskray.me/blog/2021-06-13-dependency-related-linker-options 21Position Independent thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/ • Fangrui Song, LLVM/LLD contributor: • https://maskray.me/blog/ • SystemV ABI spec and mailing list • https://groups.google0 码力 | 69 页 | 1.40 MB | 6 月前3
Shared Libraries and Where To Find Themof the systemThe linker [ld] ● Program is typically called ld ○ other implementations: ld.gold, lld, mold ● On Linux, typically invoked by gcc itself via the collect2 tool g++ my_program.cpp -o the collect2 invocation with -v ● GNU Linker is typically the default, there’s others: ○ gold, lld, mold ○ They may have slightly different behaviorsThe linker [ld] - search procedure (cont’d)The dynamic0 码力 | 94 页 | 6.49 MB | 6 月前3
Cetting Started with C++Clang/LLVMThe Big 3 – Compiler Toolchains Clang/LLVM clang / clang++ Creates object files (.o) lld Creates executables and shared libraries (.so) ar Creates static libraries (.a) llvm Attaches0 码力 | 95 页 | 4.71 MB | 6 月前3
Conan 2.0 Documentationengine/1.0: Already installed! intro/1.0: Already installed! Note: Best practices As a general rule, avoid modifying or defining values for dependencies options in consumers conanfile.py. The declared global binary compatibility assumptions. The general rule is that every different value of settings and options creates a different package_id. This rule can be relaxed or expanded following different approaches: flag with linkers that supports specifying linker scripts with the -T flag, such as ld, gold, and lld. • tools.build:sysroot defines the --sysroot flag to the compiler. • tools.build:compiler_executables0 码力 | 652 页 | 4.00 MB | 1 年前3
Conan 2.5 Documentationengine/1.0: Already installed! intro/1.0: Already installed! Note: Best practices As a general rule, avoid modifying or defining values for dependencies options in consumers conanfile.py. The declared ([DEP]/BUILD.bazel, conan_deps_module_extension.bzl and conan_deps_repo_rules.bzl) which define the rule and all the dependencies to create/load them as Bazel repositories. The MODULE.bazel above is ready global binary compatibility assumptions. The general rule is that every different value of settings and options creates a different package_id. This rule can be relaxed or expanded following different approaches:0 码力 | 769 页 | 4.70 MB | 1 年前3
Conan 2.4 Documentationengine/1.0: Already installed! intro/1.0: Already installed! Note: Best practices As a general rule, avoid modifying or defining values for dependencies options in consumers conanfile.py. The declared ([DEP]/BUILD.bazel, conan_deps_module_extension.bzl and conan_deps_repo_rules.bzl) which define the rule and all the dependencies to create/load them as Bazel repositories. The MODULE.bazel above is ready global binary compatibility assumptions. The general rule is that every different value of settings and options creates a different package_id. This rule can be relaxed or expanded following different approaches:0 码力 | 769 页 | 4.69 MB | 1 年前3
Conan 2.1 Documentationengine/1.0: Already installed! intro/1.0: Already installed! Note: Best practices As a general rule, avoid modifying or defining values for dependencies options in consumers conanfile.py. The declared global binary compatibility assumptions. The general rule is that every different value of settings and options creates a different package_id. This rule can be relaxed or expanded following different approaches: flag with linkers that supports specifying linker scripts with the -T flag, such as ld, gold, and lld. • tools.build:sysroot defines the --sysroot flag to the compiler. • tools.build:compiler_executables0 码力 | 694 页 | 4.13 MB | 1 年前3
共 139 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14













