This repository contains my C++ practice programs while studying Programming: Principles and Practice Using C++ by Bjarne Stroustrup, Third Edition.
The setup is designed for C++23 examples using GNU GCC on macOS, including support for PPP3's import std;, PPP.h, and PPP_support.h.
Chapter work belongs in folders named chNUM:
ch1/ # Chapter 1
ch2/ # Chapter 2
ch3/ # Chapter 3
PPP support files stay at the repository root and are shared by all chapter folders:
PPP.h
PPP.cxx
PPP_support.h
PPPheaders.h
scripts/pppgcc
Example Chapter 1 files:
ch1/hello.cpp
ch1/name.cpp
ch1/README.md
Build chapter programs from the repository root:
gcc ch1/hello.cpp
./hello
gcc ch1/name.cpp
./namePPP3's support header uses modules:
import PPP;That means a program such as ch1/name.cpp needs the already-built module artifacts:
gcm.cache/std.gcmandstd.oforimport std;gcm.cache/PPP.gcmandPPP.oforimport PPP;
The scripts/pppgcc wrapper automates the build and link flags needed for these files.
From the repository root:
mkdir -p ~/bin
cp scripts/pppgcc ~/bin/pppgcc
chmod +x ~/bin/pppgcc
echo 'alias gcc="$HOME/bin/pppgcc"' >> ~/.zshrc
source ~/.zshrc
type gccAfter that, this should work for normal PPP3 exercises:
gcc ch1/name.cpp
./namePPP.cxx intentionally starts with:
module;
#include <cstddef>
export module PPP;
export import std;The global module fragment gives PPP_support.h access to size_t without placing #include <cstddef> inside PPP_support.h.
See docs/PPP3_GCC_MODULES.md for the detailed troubleshooting notes from the macOS/GCC setup.