4 ms·
May I then suggest... #define if while
by toxik 5y ago
May I then suggest...
#define if while
- layer8 5y agoThat fails when you have an else. :)
- Akronymus 5y agowould that work? #define while(x) for(;true;)
- layer8 5y agoIt would cause a compile error for do-while loops. And there’s no reason to use `for` here, `while (true)` would do the same (C macros don’t expand recursively in such cases).
- Akronymus 5y agoI guess i would go with this in a header file that includes rand.h instead, then: #define while(cond) while ((cond) && rand() >= somesufficientlysmallnumber)
- toxik 5y ago#define else There!
- layer8 5y agoI think I could devise scenarios where that would fail compilation when `else` is used as a macro argument, but other than that it seems quite solid. :)