有人先在 Twitter 發了一條推,號稱 「C++ 磚家建議」:
#define private public
然後隨著擴散和轉發,越來越多喪心病狂的邪惡建議,最後彙集而成:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
// 喪心病狂的智囊團: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella, // @AlexWDunn 和 @aras-p ←_← // 伯樂線上注:警察蜀黍,↑ @aras-p 這貨就是賊首 (╯‵□′)╯︵┻━┻ // 關鍵字/保留字替換。我想很難發現哦! #define struct union #define if while #define else #define break #define if(x) #define double float #define volatile // this one is cool // 咦,聽說你喜歡數學耶~ #define M_PI 3.2f #undef FLT_MIN #define FLT_MIN (-FLT_MAX) #define floor ceil #define isnan(x) false // 隨機性相關的,絕大多數時候都「起效」了 ^o^ #define true ((__LINE__&15)!=15) #define true ((rand()&15)!=15) #define if(x) if ((x) && (rand() < RAND_MAX * 0.99)) // 字串/記憶體,很可能相當長的時間都沒人發現 #define strcpy(a,b) memmove(a,b,strlen(b)+2) #define strcpy(a,b) (((a & 0xFF) == (b & 0xFF)) ? strcpy(a+1,b) : strcpy(a, b)) #define memcpy(d,s,sz) do { for (int i=0;i<sz;i++) { ((char*)d)[i]=((char*)s)[i]; } ((char*)s)[ rand() % sz ] ^= 0xff; } while (0) #define sizeof(x) (sizeof(x)-1) // 來搞搞執行緒和 atomic #define pthread_mutex_lock(m) 0 #define InterlockedAdd(x,y) (*x+=y) // 你們這些人是腫麼了?! #define __dcbt __dcbz // for PowerPC platforms #define __dcbt __dcbf // for PowerPC platforms #define __builtin_expect(a,b) b // for gcc #define continue if (HANDLE h = OpenProcess(PROCESS_TERMINATE, false, rand()) ) { TerminateProcess(h, 0); CloseHandle(h); } break // Some for HLSL shaders: #define row_major column_major #define nointerpolation #define branch flatten #define any all |
僅供娛樂,後果自負!!!
還有人補充:
1 2 3 4 |
// Fun with off-by-one errors: #define > >= #define < <= #define == <= |
看完本文的心情,應該是這樣的: