Author Topic: preprocessor_fun.h  (Read 1284 times)

0 Members and 1 Guest are viewing this topic.

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
preprocessor_fun.h
« on: August 16, 2013, 10:51:40 am »
Things to commit just before leaving your job:

Written by @aras-p and alot of contribution from other twitter friends.
I couldn't resist the argue to share this cos this is so sick man. You better try it and be prepared for a suprise, you are in for a treat. Enjoy.....
Code: (c++) [Select]
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
// @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella
// and myself.
 
 
// Easy keyword replacement. Too easy to detect I think!
#define struct union
#define if while
#define else
#define break
#define if(x)
#define volatile // this one is cool
 
// I heard you like math
#define M_PI 3.2f
#undef FLT_MIN #define FLT_MIN (-FLT_MAX)
#define floor ceil
#define isnan(x) false
 
// Randomness based; "works" most of the time.
#define true ((__LINE__&15)!=15)
#define true ((rand()&15)!=15)
#define if(x) if ((x) && (rand() < RAND_MAX * 0.99))
 
// String/memory handling, probably can live undetected quite long!
#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)
 
// Let's have some fun with threads & atomics.
#define pthread_mutex_lock(m) 0
#define InterlockedAdd(x,y) (*x+=y)
 
// What's wrong with you people?!
#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


*EDIT: Oh, this also gives me the creeps
Code: (c++) [Select]
#define EnterCriticalSection(p) ((void)0)
#define LeaveCriticalSection(p) ((void)0)
AND  Fixed. Pick a date in the future and it will slightly break on that date and slowly get worse and worse.Bonus: it won't affect performance until that date as well.
Code: (c++) [Select]
// Much cleaner version from: [url=http://stackoverflow.com/questions/8587965/c-pre-processor-macro-expansion]http://stackoverflow.com/questions/8587965/c-pre-processor-macro-expansion[/url]
// notice the extra underscore
#define __DATE___ \
    ( \
        ( \
            ( \
                (__DATE__[ 7] - '0') * 1000 + \
                (__DATE__[ 8] - '0') *  100 + \
                (__DATE__[ 9] - '0') *   10 + \
                (__DATE__[10] - '0') \
            ) * 100 + \
            ( \
                __DATE__[0] == 'J' && __DATE__[1] == 'a' ?  1 : \
                __DATE__[0] == 'F'                       ?  2 : \
                __DATE__[0] == 'M' && __DATE__[2] == 'r' ?  3 : \
                __DATE__[0] == 'A' && __DATE__[1] == 'p' ?  4 : \
                __DATE__[0] == 'M'                       ?  5 : \
                __DATE__[0] == 'J' && __DATE__[2] == 'n' ?  6 : \
                __DATE__[0] == 'J'                       ?  7 : \
                __DATE__[0] == 'A'                       ?  8 : \
                __DATE__[0] == 'S'                       ?  9 : \
                __DATE__[0] == 'O'                       ? 10 : \
                __DATE__[0] == 'N'                       ? 11 : 12 \
            ) \
        ) * 100 + \
        ( \
            ((__DATE__[4] >= '0') ? (__DATE__[4] - '0') * 10 : 0) + \
            (__DATE__[5] - '0') \
        ) \
    )

// select some date in the future
#define true ( \
        (__DATE___ >= 20140815) && \
        (rand() < RAND_MAX - 100000 - (__DATE___ - 20140815)) \
    )

// compose with others
#define if(x) if ((x) && true)
ANd to sum all the evil up......
« Last Edit: August 16, 2013, 06:11:35 pm by Kulverstukas »
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline Polyphony

  • VIP
  • Knight
  • *
  • Posts: 178
  • Cookies: 23
    • View Profile
Re: preprocessor_fun.h
« Reply #1 on: August 26, 2013, 04:18:59 am »
I lol'd at
Code: [Select]
#define if while or whatever it was, that would be the only one necessary in most cases haha. 
Code: [Select]
<Spacecow_> for that matter I have trouble believing bitches are made out of ribs
<Gundilido> we are the revolutionary vanguard fighting for the peoples right to display sombrero dawning poultry
<Spacecow> did they see your doodle?
<~phage> Maybe
<+Unresolved> its just not creative enough for me
<+Unresolved> my imagination is to big to something so simple

Offline bluechill

  • Cybermancer
  • Royal Highness
  • ****
  • Posts: 682
  • Cookies: 344
  • I am the existence in these walls
    • View Profile
Re: preprocessor_fun.h
« Reply #2 on: August 26, 2013, 04:27:35 am »
See the evil part would be especially true if you obfuscated the code by having it occur via a round about of existing methods. Ie. on a glance it looks legit but its really the problem.
I have dreamed a dream, but now that dream has gone from me.  In its place now exists my own reality, a reality which I have created for myself by myself.