3 ms·
Ever waste days debugging a subtle bug introduced by C macros? It's PTSD material. I love C but I will never understand why C has a naive macro system.
by dynamicvariable 8y ago
Ever waste days debugging a subtle bug introduced by C macros? It's PTSD material.
I love C but I will never understand why C has a naive macro system.
- anitil 8y agoI always thought it was a historical choice that simple substitution languages were simpler to implement so were chosen as a default. It is kind of infuriating that the preprocessor always feels simultaneously _too powerful_ and _not powerful enough_ for the jobs you want to get done. I find myself reaching for other tools (kaitai, m4 etc) a lot more these days to take the role.
- dexen 8y agoThe kenc[1] compiler subsequent to K&R C had much more constrained macro system exactly for those reasons. Thanks to advances in optimization and improved machine speed, it was reasonable to skip preprocessor-level const operations. Thanks to dead code elimination it was feasible to mostly give up conditional compilation. [1] as used, for example, in Plan 9.