Уровень 0 · материалов: 6
В кластер включены документы, посвященные функциональности, применению и рискам использования макросов и препроцессора в языках C/C++, и исключены материалы о синтаксических загадках или устаревших последовательностях символов (триграфах).
Общие признаки: использование директив #define, метапрограммирование, ошибки и уязвимости макросов, манипуляции с исходным кодом до компиляции
Группа выше: Неопределённое поведение и тонкости языка
Смысл: The text is a satirical collection of 'anti-patterns' and malicious macros intended to sabotage a C++ project. The main idea is to showcase how the preprocessor can be used to create non-obvious, catastrophic bugs that are extremely difficult to diagnose.
A humorous but malicious guide on using C++ preprocessor macros to covertly sabotage a codebase before quitting a job.
Смысл: The text demonstrates how redefining standard library functions as macros can lead to subtle logical errors and redundancy in code, emphasizing the value of static analysis tools in detecting such bugs.
A bug in GNU Midnight Commander's 'EatWhitespace' function, caused by a custom 'isspace' macro, illustrates the danger of redefining standard functions and the effectiveness of static analysis.
Смысл: The author explores the theoretical and practical limits of the C preprocessor, demonstrating that it is possible to implement complex logic—including a simulated array and recursive functions—using only #define directives. The main idea is to show that through 'black magic' (metaprogramming), one can achieve Turing-complete-like behavior in a tool designed only for simple text substitution.
An exploration of how to implement recursive logic and data structures using only C preprocessor macros to achieve a form of Turing completeness.
Смысл: The main idea is that while macros in C/C++ are often discouraged due to their potential to introduce hard-to-debug errors, they remain a powerful tool for code generation and efficiency if strict safety rules regarding parentheses, side effects, and scoping are followed.
A technical guide explaining how C/C++ macros work, their advanced features, and the essential safety rules required to avoid common bugs.
Смысл: The main idea is that while preprocessor macros in C++ can be dangerous and error-prone if misused, they can be beneficial and improve code clarity if created following specific safety guidelines and best practices.
An exploration of the dangers and benefits of C++ macros, providing a guide on how to write 'safe' macros and demonstrating several useful utility examples.
Смысл: The text demonstrates a humorous way to rewrite C++ code by using macros to replace English keywords with archaic Russian words, effectively creating a 'Boyar' version of the language to build a simple calculator.
A C++ programmer uses preprocessor defines to create a 'Boyar' (archaic Russian) dialect for a simple calculator program as a creative coding exercise.