I would say that although you should avoid the pre-processor for most of all that you usually do, it is still necessary.
For example, in C ++, a preprocessor is required to write a unit testing library such as Catch . They use it in two different ways: one for expanding statement 1 and one for nesting sections in test cases 2 .
But the preprocessor should not be abused to perform compile-time calculations in C ++, where const constructors and meta-programming expressions can be used.
Sorry, I don't have enough reputation to post more than two links, so I put this here:
- github.com/philsquared/Catch/blob/master/docs/assertions.md
- github.com/philsquared/Catch/blob/master/docs/test-cases-and-sections.md
Hagai akibayov
source share