6 ms·
I think a good rule of thumb is to only use the preprocessor to generate code that you would be comfortable writing yourself. Spaghetti produced by macros is s
by fancydriving 15y ago
I think a good rule of thumb is to only use the preprocessor to generate code that you would be comfortable writing yourself. Spaghetti produced by macros is still spaghetti.
The article reminded me of queue.h from BSD (http://www.openbsd.org/cgi-bin/cvsweb/src/sys/sys/queue.h?rev=1.35;content-type=text%2Fplain http://www.openbsd.org/cgi-bin/cvsweb/src/sys/sys/queue.h?re...), but those macros expand to readable code.
- ay 15y agoThese macros are nothing compared to what I consider a real abuse of the preprocessor - a whole functional language implemented just by that! Search for "chaos-pp" in this entry (which has plenty of other wonders too!): http://stackoverflow.com/questions/652788/what-is-the-worst-real-world-macros-pre-processor-abuse-youve-ever-come-across http://stackoverflow.com/questions/652788/what-is-the-worst-...