Rico's Nerd Cluster

「离开世界之前 一切都是过程」

C++ - GTest

GTest For ROS

Concepts Google Test (a.k.a GTest) is an open source unit testing structure. From the official website Test Suite vs Test Case: A test suite contains one or many tests. You should group your t...

ROS - GDB

GDB for ROS, Core Dump

Introduction GDB is EXTREMELY handy. I used to doing a lot of print statements, but now I use GDB a lot. The reason is simple: I can check multiple things at once without recompiling everytime, es...

C++ - [Compilation 5] Compilation Speed Ups

Header-only Library Hurts Compilation Time My halo library takes ~2-3min to compile. I have ~20 executables, each executable does target_include_files(70_header_files). Why It’s Slow Every tr...

C++ - [Compilation 4] Name Mangling

nm

Motivating Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 void foo(){ const size_t N = 100'000'000; std::vector<int> v(N); // fill v with 1,2,3,... std::...

C++ - [Compilation 3] Linkage

In C++, Linkage is Either External Or Internal

Linkage In C and C++, linkage determines the accessibility of functions & variables defined in one source file in other different translation units (i.e., different source files). There are t...

C++ - [Compilation 2] Compiler Directives

Macros, Pragmas, Attributes

Introduction Compiler directives are instructions that are not part of C++ / C standards, but tell the compiler how to compile the code. They starts with # (pronounced as “hash”), and are handled ...

C++ - ABI Compatibility

ABI Compatibility: Introduction and Motivating Example ABI stands for Application Binary Interface. Two versions of the same library might be API-Compatible (you can recompile your code), but they...

C++ - Pimpl Idiom

Minimal Structure 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // header // Widget.hpp #pragma once #include <memory> class Widget { public: Widget(); ~Widget(); void doSomething...

C++ - Smart Pointers

unique_ptr, shared_ptr

Common Operations Reset: std::unique_ptr::reset() and std::shared_ptr::reset unique_ptr::reset() is basically basically delete ptr; ptr = nullptr std::shared_ptr::reset() can be a bit slower...

C++ - Streams

Stringstream, iostream, string

Streams fstream Open a file, then start appending to the file: 1 std::ofstream ofs(filename, std::ios::out | std::ios::app); How to add a custom print function? 1 2 3 4 5 inline std::...