DEV Community

Discussion on: Code Smell 56 - Preprocessors

Collapse
 
netch80 profile image
Valentin Nechayev

runtimeEnvironment->traceDebug("trace message");

Maybe the best variant is when the use calls look that simple, but, at compiler level, they are instantiated with real code or with stubs, depended on compiler directives. So all these #if are concentrated in declaration source. In a project, we used this in a variant with two level axes, so, for example, DEBUG_MIN is compiled always (with runtime check) but DEBUG_MAX if log set is >=MAX during compilation.

For regrets on preprocessor, the main problem with it is not preprocessing itself - but its low level (just textual replacement). Common LISP is fundamentally based on preprocessor but it is really high-level, with content analyzer. If an analog was added to C++, most of template magic wouldn't be needed.