TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  PRE#001Checked automatically with code checker

Synopsis:Do not define macros instead of constants, enums, or type definitions
Severity Level:7


A disadvantage of macros is that they can have side-effects and that they are not type-safe. In C++ alternatives exists that do not have these drawbacks. An alternative for a macro constant is the use of a const or enum, as in:

#define MAX_BUFFER_LENGTH  1000        // Not ok.
const ULONG ulMaxBufferLength = 1000;  // Ok.
enum {MAX_BUFFER_LENGTH = 1000};       // Ok.