C ++ macros use

This article summarize the contents section 1.3 "Game Programming Gems 3" and met its own or used in the project macro skills.

The use of macros can be roughly divided into three categories:

One test, for example, assert its variants, compile-time assertions, prevent infinite loops, __ FILE__, etc., these macros will usually be replaced with a blank in the Release version;

Second, function, some of the features implemented by the macro may be more convenient or better performance (runtime moved to work to compile a), such as examples of "Game Programming Gems 3," 1.3.3, at compile time to achieve a binary turn hex;

Third simple, comprising reducing code duplication (thus reducing the time code changes), to improve readability, examples of such "Implementing a State Machine Language", simplifying the interface class (subclass duplicate function head macro instead of) and so on.

Guess you like

Origin www.cnblogs.com/saltedreed/p/12598089.html