3 ms·
That's exactly the problem with C macros, they can do everything.
by stefan_ 5y ago
That's exactly the problem with C macros, they can do everything.
- wruza 5y agoAnother problem with them is they can’t. Personally I’ve never run in a macro problem in C (and I find these abstract complaints overblown and a little parroting, but ymmw), but their power is far from absolute because it’s just a text concatenation method, not a source code or a type editing method. As an example exercise, you may try to implement: { FILE *f = fopen(…); on_leave_scope(if (f) fclose(f)); } Inability to do that, i.e. to get access to the language structure and fix it according to your convenience, combined with non-hygiene, was what led to C++ compilers and other hardcoded madness.
- Someone 5y agoNot exactly that, but certainly in its spirit: https://stackoverflow.com/questions/69336050/how-to-implement-gos-defer-in-c-so-that-it-allows-declaring-vars https://stackoverflow.com/questions/69336050/how-to-implemen... Also, what some all hardcoded madness is what others call consistency across code bases.