Question about best practices and Macros from the book 'C++ Coding Standards'
Posted
by
Victor T.
on Stack Overflow
See other posts from Stack Overflow
or by Victor T.
Published on 2011-01-08T12:38:17Z
Indexed on
2011/01/08
12:53 UTC
Read the original article
Hit count: 262
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
© Stack Overflow or respective owner