/ I'm Kenny, and I'm a programmer.

C++ journal

Language basics

Built-in types

TypeSize
bool-
char8 bits
wchar_t16 bits
char16_t16 bits
char32_t32 bits
short16 bits
int16 bits
long32 bits
float6 significant digits
double10 significant digits
long double10 significant digits

Functions

constexpr int name_of_function(string arg1 = 'default', ....) {
  // code here

  return 42;
}

Exceptions

Macros

Classes

Pointers

Templates

Other bits

Compilation process

Stages of compilation

  1. Lexical analysis (tokenization)
  2. Syntax analysis (parse tree)
  3. Semantic analysis (type checking, object binding, assignment)
  4. Code generation (IR to machine code)

Concretely, we can also describe the end to end as follows,

  1. Preprocessor
  2. Parsing
  3. Generate IR (immediate representation)
  4. Compiler backend (IR to assembly code)
  5. Assembler (assembly code to machine code)
  6. Linker (machine code to shared object or executable)

The outcome is either a shared object or an executable (with instructors for the OS loader)

Translation (from source to object)

Files

Toolchain

Clang

Clang tooling

Other nice things

🕑 20Z14