C++ Under the Microscope: The Preprocessor Unmasked
Автор: DeadBugLogic
Загружено: 2026-03-06
Просмотров: 14
Описание:
The C++ preprocessor is older than C++ itself. It's also more powerful—and more dangerous—than most developers realize.
In this episode of C++ Under the Microscope, we go deep into the preprocessor. Not just #include and simple macros. We look at what actually happens when the preprocessor runs, and how to use it for:
• X-Macros – Generate enums AND string tables from one list
• ASSERT macros that capture file/line context
• Token pasting (##) to fake generics
• Variadic macros and the VA_OPT
• Macro "recursion" with the REPEAT trick
• Compile-time arithmetic with #if
• Include guards vs #pragma once
• _Pragma – Injecting compiler instructions from macros
We also look at the expanded output every step of the way. Because if you don't understand what the preprocessor actually generates, you don't understand what you wrote.
⏱️ Timestamps:
0:00 – Intro: It's just text replacement... right?
0:57 – X-Macros: Data-driven code generation
2:20 – ASSERT macro: Capturing context
5:19 – Token pasting: Fake generics
6:50 – Variadic macros and VA_OPT
8:47 – Macro "recursion": The REPEAT trick
13:27 – Conditional arithmetic
15:10 – Include guards vs #pragma once
16:49 – _Pragma: Injecting compiler instructions
18:50 – Final words
#cpp #programming #preprocessor #xmacros #cplusplus #coding
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: