Linux and C++ Systems Notes

Linux and C++ Systems Notes Originally published in Chinese on 2022-01-18; this English edition preserves the original scope and technical context. Linux: I mostly complete my learning on Linux. I currently have two computers, an iMac and a laptop, where the laptop is running Linux. I use many commands daily, such as using pipeline outputs with grep for regular expression searches, ifconfig and netstat to check network status, top to view process resources, and iostat to monitor CPU and disk states. I also use basic commands like cd, ls, cp, rm, mkdir, find, and whereis. Additionally, I use scp for remote operations. I also use system calls (open, close, read, write, ioctl, etc.) to interact with the file system in Linux, whereas on macOS, I use dtruss. ...

January 18, 2022 · 3 min · Zhengyu Chen

Effective C++ Notes

Effective C++ Notes Originally published in Chinese on 2020-09-24; this English edition preserves the original scope and technical context. 0 Introduction 1 Constructors Default constructor: A constructor that can be called without any arguments. Such a constructor must either have no parameters or have parameters with default values, for example. class Bar { public: // explicit Bar(); // is default constructor // explicit Bar(int x = 0) // is not default constructor explicit Bar(int x = 0, bool b = true); // is default constructor private: int x; bool b; }; explicit keyword: Prevents implicit type conversions, its advantage being the prohibition of the compiler performing unexpected type conversions, such as ...

September 24, 2020 · 17 min · Zhengyu Chen

Exploring boost::typeindex

Exploring boost::typeindex Originally published in Chinese on 2020-07-31; this English edition preserves the original scope and technical context. boost::typeIndex’s Related Exploration Effective Modern C++ Item 4: Know how to view deduced types. mentions the use of Boost::typeindex, but does not discuss its implementation. 1. typeid Operator typeid is a operator in C++ used to obtain information about a type. It is often used where a known dynamic type of polymorphic objects is needed, or to identify static types. ...

July 31, 2020 · 10 min · Zhengyu Chen

An Introduction to CMake

An Introduction to CMake Originally published in Chinese on 2020-06-21; this English edition preserves the original scope and technical context. 0. Preface CMake is an open-source, cross-platform build tool that makes managing the directory structure of multiple libraries and dependencies easy, and generates makefile that can be used with GNU make to compile and link a program. 1. Building a Single File 1.1 Using GCC to Compile Assume that we wish to write a function to implement safe integer addition to prevent overflow, and this source file has no dependencies or static libraries: ...

June 21, 2020 · 16 min · Zhengyu Chen

An Introduction to Debugging with GDB

An Introduction to Debugging with GDB Originally published in Chinese on 2020-04-22; this English edition preserves the original scope and technical context. Zero. Introduction Debugging is an essential part of the development process. When developing on Windows or MacOS, one can use debugging features in IDEs like VS and CLion to set breakpoints or inspect variables and stacks. However, on Linux, there is no graphical interface available. If one relies solely on logging to find issues, the efficiency will be very low. At this point, we can leverage GDB to enhance our development efficiency. ...

April 22, 2020 · 9 min · Zhengyu Chen