2 ms·
Author of the linked gist here. Some backstory: someone tweeted a "C++ protip: #define private public" joke. I replied with the excellent "#define struct union
by aras_p 13y ago
Author of the linked gist here. Some backstory: someone tweeted a "C++ protip: #define private public" joke. I replied with the excellent "#define struct union - saves memory!" that I saw somewhere (all valid C programs will still compile, though not necessarily C++ ones).
And then twitter conversation went to more and more evil suggestions. I just captured them in the gist.
My favorites are "#define strcpy(a,b) memmove(a,b,strlen(b)+2)" - which can go unnoticed in a long, long time; and "#define InterlockedAdd(x,y) (*x+=y)" - which would be total hell for someone to debug, as if lockless programming wouldn't be hard enough already.
- markjdb 13y ago> all valid C programs will still compile, though not necessarily C++ ones I don't think that's true: struct foo { int a; int b; }; char arr[sizeof(struct foo) == sizeof(int) ? -1 : 1];
- aras_p 13y agoOk, proved me wrong! The ones that check for struct sizes at compile time (like in your example) will fail since sizes will be different now.