5 ms·
Not to forget #define struct union which will pack all struct members together. Gives me chills even to think about it...
by shaneeb 14y ago
Not to forget #define struct union which will pack all struct members together. Gives me chills even to think about it...
- nostrademons 14y agoThe #define else one is scarier to me. #define struct union will almost certainly crash immediately on runtime, as one member's a pointer and it gets overwritten by an int or a pointer to a different type. #define else just always runs all else clauses - the code is likely still valid, it just does something very different from what the author intended. Both of them would be a real pain to debug.
- jongraehl 14y agoBoth would be easy to notice in a debugger. Finding the cause, as you imply, would be tricky unless you remember to check the preprocessed output.
- AnthonyMouse 14y agoCan anyone think of a reason why all the examples are keywords? I would think if you were trying to cause some trouble, redefining standard functions would cause all kinds of chaos, e.g. #define memmove memcpy #define strncmp memcmp #define rand fork #define free(x) #define strerror(n) strerror((n)+1) #define memset(addr, byte, len) memset(addr, ~(byte), len)
- eru 14y agoIt's a great memory saver.