X Macros: Difference between revisions

m 1 revision
m that looked retarded
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 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>struct</tt>s, <tt>union</tt>s, and <tt>enum</tt>s)
* Aggregates (names of <tt>structs</tt>, <tt>unions</tt>, and <tt>enums</tt>)
* Members within each aggregate
* Members within each aggregate
* Labels
* Labels