More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions

I l @ ve RuBoard

Item 35. #Definition

Difficulty: 4

What can and can't macros do? Not all compilers agree.

  1. Demonstrate how to write a simple max() preprocessor macro that takes two arguments and evaluates to the one that is greater, using normal < comparison. What are the usual pitfalls in writing such a macro?

  2. What can a preprocessor macro not create? Why not?

I l @ ve RuBoard

Категории