C++ uses macros to control comments

In C++, macro definitions can be used to control whether part of the code needs to be commented.
1. First define a macro "HONG" in front, and then write "#ifdef" and "#endif" before and after the code that needs to be controlled in the code , then you can use HONG to control whether the code is enabled, so as to replace comments and make code editing more convenient and beautiful.
2. When you do not need to enable the code, that is, when you want to comment this paragraph, just comment out the "#define HONG" in front of it. It is very convenient to start and uncomment "#define HONG".
example:

#define HONG

*
正常code
*

#ifdef HONG
	*
	需要被控制的code
	*
#endif

Guess you like

Origin blog.csdn.net/weixin_44650358/article/details/127222014