X Macros: Difference between revisions
m 1 revision |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
The C/C++ preprocessor expands a nested macro only when the subsuming macro is expanded, as opposed to defined. It also allows macros to be redefined. This leads to an elegant and powerful technique, not used nearly widely enough, for eliminating unmaintainable duplications. The problem originates in C's divergent (tetrapartite, to be precise) syntactic namespace: | The [[ISO C99|C]]/C++ preprocessor expands a nested macro only when the subsuming macro is expanded, as opposed to defined. It also allows macros to be redefined. This leads to an elegant and powerful technique, not used nearly widely enough, for eliminating unmaintainable duplications. The problem originates in C's divergent (tetrapartite, to be precise) syntactic namespace: | ||
* Aggregates (names of <tt> | * Aggregates (names of <tt>structs</tt>, <tt>unions</tt>, and <tt>enums</tt>) | ||
* Members within each aggregate | * Members within each aggregate | ||
* Labels | * Labels | ||