Question about best practices and Macros from the book 'C++ Coding Standards'
- by Victor T.
From Herb Sutter and Andrei Alexandrescu's 'C++ Coding Standards', Item 16: Avoid Macros under Exceptions for this guideline they wrote:
For conditional compilation (e.g.,
system-dependent parts), avoid
littering your code with #ifdefs.
Instead, prefer to organize code such
that the use of macros drives
alternative implementations of one
common interface, and then use the
interface throughout.
I'm having trouble understanding exactly what they mean by this. How can you drive alternate implementations without the use of #ifdef conditional compile macro directives? Can someone provide an example to help illustrate what's being proposed by the above paragraph?
Thanks