Skip to content

Instantly share code, notes, and snippets.

@qingswu
Forked from aras-p/preprocessor_fun.h
Created May 18, 2016 11:17

Revisions

  1. @aras-p aras-p revised this gist Aug 16, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions preprocessor_fun.h
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,7 @@
    #define else
    #define break
    #define if(x)
    #define double float
    #define volatile // this one is cool

    // I heard you like math
  2. @aras-p aras-p revised this gist Aug 16, 2013. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions preprocessor_fun.h
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@
    //
    // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
    // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
    // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella
    // and myself.
    // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella,
    // @AlexWDunn and myself.


    // Easy keyword replacement. Too easy to detect I think!
    @@ -46,3 +46,9 @@
    #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
  3. @aras-p aras-p revised this gist Aug 15, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions preprocessor_fun.h
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@
    // 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
  4. @aras-p aras-p renamed this gist Aug 14, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @aras-p aras-p revised this gist Aug 14, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion code.c
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    #define else
    #define break
    #define if(x)
    #define volatile
    #define volatile // this one is cool

    // I heard you like math
    #define M_PI 3.2f
  6. @aras-p aras-p revised this gist Aug 14, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion code.c
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,8 @@
    //
    // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
    // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
    // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic and myself.
    // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella
    // and myself.


    // Easy keyword replacement. Too easy to detect I think!
    @@ -13,6 +14,7 @@
    #define else
    #define break
    #define if(x)
    #define volatile

    // I heard you like math
    #define M_PI 3.2f
  7. @aras-p aras-p revised this gist Aug 14, 2013. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions code.c
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    //
    // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
    // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
    // @KarlHillesland, @rexguo, @tom_forsyth and myself.
    // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic and myself.


    // Easy keyword replacement. Too easy to detect I think!
    @@ -35,7 +35,8 @@
    #define pthread_mutex_lock(m) 0
    #define InterlockedAdd(x,y) (*x+=y)

    // Uh-oh.
    // 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
  8. @aras-p aras-p revised this gist Aug 14, 2013. 1 changed file with 18 additions and 3 deletions.
    21 changes: 18 additions & 3 deletions code.c
    Original file line number Diff line number Diff line change
    @@ -3,24 +3,39 @@
    // Preferably into the same commit where you do a large merge.
    //
    // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
    // @YuriyODonnell, @rygorous and myself. Never let these guys
    // change jobs! :)
    // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
    // @KarlHillesland, @rexguo, @tom_forsyth 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 true (__LINE__&1)
    // 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)

    // Uh-oh.
    #define __dcbt __dcbz // for PowerPC platforms
    #define __dcbt __dcbf // for PowerPC platforms
    #define __builtin_expect(a,b) b // for gcc
  9. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions code.c
    Original file line number Diff line number Diff line change
    @@ -23,3 +23,4 @@
    #define InterlockedAdd(x,y) (*x+=y)

    #define __dcbt __dcbz // for PowerPC platforms
    #define __builtin_expect(a,b) b // for gcc
  10. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion code.c
    Original file line number Diff line number Diff line change
    @@ -10,12 +10,15 @@
    #define struct union
    #define if while
    #define else
    #define break
    #define if(x)

    #define true (__LINE__&1)
    #define true ((rand()&15)!=15)
    #define strcpy(a,b) memmove(a,b,strlen(b)+2)
    #define if(x) if ((x) && (rand() < RAND_MAX * 0.99))

    #define strcpy(a,b) memmove(a,b,strlen(b)+2)

    #define pthread_mutex_lock(m) 0
    #define InterlockedAdd(x,y) (*x+=y)

  11. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion code.c
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,6 @@
    #define if(x) if ((x) && (rand() < RAND_MAX * 0.99))

    #define pthread_mutex_lock(m) 0
    #define InterlockedAdd(x,y) (*x+y)
    #define InterlockedAdd(x,y) (*x+=y)

    #define __dcbt __dcbz // for PowerPC platforms
  12. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion code.c
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,9 @@
    #define true (__LINE__&1)
    #define true ((rand()&15)!=15)
    #define strcpy(a,b) memmove(a,b,strlen(b)+2)
    #define if(x) if ((x) && (rand() < RAND_MAX * 0.99))

    #define pthread_mutex_lock(m) 0
    #define InterlockedAdd(x,y) (*x+y)
    #define InterlockedAdd(x,y) (*x+y)

    #define __dcbt __dcbz // for PowerPC platforms
  13. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions code.c
    Original file line number Diff line number Diff line change
    @@ -14,3 +14,6 @@
    #define true (__LINE__&1)
    #define true ((rand()&15)!=15)
    #define strcpy(a,b) memmove(a,b,strlen(b)+2)

    #define pthread_mutex_lock(m) 0
    #define InterlockedAdd(x,y) (*x+y)
  14. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions code.c
    Original file line number Diff line number Diff line change
    @@ -3,12 +3,14 @@
    // Preferably into the same commit where you do a large merge.
    //
    // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
    // @YuriyODonnell and myself. Never let these guys change jobs! :)
    // @YuriyODonnell, @rygorous and myself. Never let these guys
    // change jobs! :)


    #define struct union
    #define if while
    #define else
    #define if(x)
    #define true ((rand()&15)!=15)
    #define true (__LINE__&1)
    #define true ((rand()&15)!=15)
    #define strcpy(a,b) memmove(a,b,strlen(b)+2)
  15. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion code.c
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,8 @@
    // Add one of these.
    // Preferably into the same commit where you do a large merge.
    //
    // From @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, @YuriyODonnell
    // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
    // @YuriyODonnell and myself. Never let these guys change jobs! :)


    #define struct union
  16. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions code.c
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    // Just before switching jobs:
    // Add one of these.
    // Preferably into the same commit where you do a large merge.
    //
    // From @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, @YuriyODonnell


    #define struct union
    #define if while
  17. @aras-p aras-p revised this gist Aug 13, 2013. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion code.c
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,10 @@
    // Just before switching jobs:
    // Add one of these.
    // Preferably into the same commit where you do a large merge.

    #define struct union
    #define if while
    #define else
    #define if(x)
    #define true ((rand()&15)!=15)
    #define true (__LINE__&1)
    #define if(x)
  18. @aras-p aras-p created this gist Aug 13, 2013.
    6 changes: 6 additions & 0 deletions code.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #define struct union
    #define if while
    #define else
    #define true ((rand()&15)!=15)
    #define true (__LINE__&1)
    #define if(x)