Home / Forums / What are C++20 Modules and how do they replace traditional header files? [Discussion #9]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

What are C++20 Modules and how do they replace traditional header files? [Discussion #9]

VMT_Hooker
VMT / Detours Engineer
VIP
Rep: 310
Join Date: Mar 2023
Posts: 22
Thanks: 80
4y ago · Mar 7, 2022 8:18 AM
#1
How do C++20 Modules (.ixx / .cppm) compare to traditional .h and .cpp file structures? Do they actually eliminate header guards and speed up build times?
VMT_Hooker - Virtual method table swapping made easy
The following users thanked VMT_Hooker for this post:
StructMapper
SDK & Class Builder
MEMBER
Rep: 160
Join Date: May 2024
Posts: 26
Thanks: 39
4y ago · Mar 7, 2022 9:49 AM
#2
Modules compile once into a binary Module Interface File (BMI / IFC). When another translation unit imports the module (import MyModule;), the compiler loads the pre-parsed AST directly instead of re-tokenizing thousands of lines of text! Macro leaks across files are completely prevented.
StructMapper | ReClass.NET & Class Layouts
PEHeader
PE Format & Linker Tech
VIP
Rep: 350
Join Date: Jun 2023
Posts: 35
Thanks: 95
4y ago · Mar 7, 2022 2:49 PM
#3
Build times on large projects drop dramatically because header parsing is no longer duplicated across every single .cpp file.
PEHeader | IMAGE_NT_HEADERS & Section Parsing