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.
8 comments
[ 3.4 ms ] story [ 32.5 ms ] threadHere's an old gem I came across a few years back:
https://gist.github.com/bsamuels453/5819204
This is a bitch to detect if you have a huge project. The #ifndef _DEBUG is like frosting on the cake. Templates are truly C++'s greatest 'gift'
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.
I don't think that's true: