Skip to content

Latest commit

 

History

History
15 lines (8 loc) · 925 Bytes

File metadata and controls

15 lines (8 loc) · 925 Bytes

<<< Table of contents

Macros

  1. The use of macros is strongly discouraged. Avoid macros at all cost.

    • The preprocessor is just a stupid text replacement tool and should be avoided at all cost. It is completely unaware of type safety/type checking and not obeying scoping. Defined macros are not debuggable and sooner or later will lead to nasty side effects (e.g. multiple increment problem).

    • C++ provides vastly better tools for any imaginable use of macros; use inline functions or lambdas instead. The use of #define outside of header include guards or conditional compilation has no place in modern C++ programming.

    • Exception: A macro can still be useful (and the only way, unfortunately) to implement a custom assert() facility, when using the predefined macros FILE and LINE.


<<< Table of contents