Est. read time: 2 minutes | Last updated: February 23, 2024 by John Gentile


Contents

The Language

C++ has language facilities similar to the C language such as being a procedural programming language but is vastly different in many ways.


CppCon has great talks on new C++ features as well.

The Basics

The proverbial “Hello, World!” implementation in C and C++ introduces a few basic parts of the language.

C:

#include <stdio.h>

main()
{
  printf("Hello, World!\n");
}

C++:

#include <iostream>

int main()
{
  std::cout << "Hello, World!\n";
}

Tools

Building C++ Programs

C++ must be compiled from source files into object files and then linked into an executable file.

cpp_linking

C++ is a statically typed language in that every entity (i.e. object, name, value, etc.) must be known to the compiler at compile-time.

Compilers

GNU cc (gcc)

gcc is a common compiler for the C language (as well as C++ and Objective C). Debug information and optimizations can also be utilized.

Online Compilers

  • ideone: Online compiler and debugging tool that supports over 60 code languages
  • godbolt: Compiler explorer to examine machine code output for various compile chains supporting a couple code languages (C++, D, Rust, and Go)

Build Systems

GNU Make

When a makefile exists for a given directory/project (under the form makefile, Makefile) simply running the shell command $ make executes commands and instructions given in the makefile.

CMake

LLVM/Clang

Code Analysis Tools

  • Valgrind: instrumentation framework to detect memory management and threading bugs.
  • Facebook Infer: static analysis of C/C++/Objective-C and Java code.
  • clangd Language Server: adds code completion, compile errors, go-to-definition and other features to tools that use the Language Server Protocol (LSP).
    • clang-tidy: linting tool for style violations, interface misuse or bugs that can be deduced via static analysis.
    • clang-format: a tool to format C/C++ (and other similar language) code.
    • oclint: static source code analysis tool for C/C++ and Objective-C.
      • cppcheck: another static analysis tool for C/C++ code.

Other Tools

  • cdecl: C gibberish ↔ English translator.
  • Doxygen: generates documentation from inline comments in source code.

C++ Libraries

References

C

C++