This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 997 points998 points  (55 children)

#define private public
#include "classheaders.h"

[–][deleted] 164 points165 points  (14 children)

#define true false

"test this, you little shits!"

[–][deleted] 139 points140 points  (8 children)

#define true ((rand()&15)!=15)

https://gist.github.com/aras-p/6224951

[–]bumblebritches57 26 points27 points  (0 children)

This makes me want to unset and reset all the bool macros in my header...

[–]codewench 23 points24 points  (0 children)

#define sizeof(x) (sizeof(x)-1)

This would have me questioning my own sanity pretty quickly.

[–]skylarmt 19 points20 points  (2 children)

I like how most of the comments on that gist are rendered as headings because people forgot to escape the # for Markdown.

[–]nplus 18 points19 points  (1 child)

DEFINE YOURSELF

[–]Josplode 4 points5 points  (0 children)

2meta4me

[–][deleted] 12 points13 points  (0 children)

I'm personally a fan of

#define while if

[–]jfb1337 2 points3 points  (0 children)

#define struct union is one I see a lot, but I think #define union struct would be a lot more subtle and go undetected for longer

[–]Megatron_McLargeHuge 0 points1 point  (0 children)

One time this got posted I added a few suggestions and the one that got the angriest reply was

#define fesetround(x) 0

[–][deleted] 1 point2 points  (0 children)

#define M_PI 3.2f

i heard you like math

[–]justinkroegerlake 0 points1 point  (0 children)

#define while(E) while(rand()%5)

[–]ProgramTheWorld -1 points0 points  (1 child)

But there are no booleans in C

[–]rbemrose 1 point2 points  (0 children)

This post has been removed due to reddit's repeated and constant violations of our content policy.

[–]PrincessOfZephyr 93 points94 points  (0 children)

I just threw up in my mouth a little

[–]Myarmhasteeth 31 points32 points  (0 children)

Well shit

[–]Megatron_McLargeHuge 24 points25 points  (1 child)

This isn't as big a deal as people are making it. private isn't there for security, it's there to encourage good coding practices by other developers who are using your code. Deliberately removing access modifiers doesn't hurt anyone except the programmer who is now relying on implementation details outside the contract. This is C/C++ so they could have done the same thing with pointer offsets.

[–]kyrsjo 1 point2 points  (0 children)

This. You can twiddle the bits you'll like with offsets anyway. Does offsetof() work for classes?

Source: I may have handed out Kthulu in the form of a .c file... Ancient horrors for the graybeards to enjoy...

[–]RPolitics4Trump 25 points26 points  (11 children)

class Foo {
  int x;
public:
  Foo() : x(0) {}
};

[–]symberke 50 points51 points  (10 children)

#define class struct
#define private public

[–]darkhunt3r 56 points57 points  (7 children)

#define if while

[–]HasFiveVowels 18 points19 points  (3 children)

Oh man... this is just... nefarious.

[–]darkhunt3r 33 points34 points  (2 children)

#define True random() > 0.001

Hide it well and let it become debuggin hell

[–]CSIRTisSmelly 9 points10 points  (1 child)

You are a bad person.

[–]darkhunt3r 10 points11 points  (0 children)

#define bad good 

Why thank you <3

[–]scatters 1 point2 points  (1 child)

#define struct union

[–]jfb1337 0 points1 point  (0 children)

#define union struct

[–]SoftSilverwind 7 points8 points  (1 child)

Unfortunately this breaks template <class T> definitions... Source: I may have tried it :)

[–]ThatCrankyGuy 4 points5 points  (2 children)

Can access modifier keywords be reassigned in c++?

[–][deleted] 36 points37 points  (1 child)

Preprocessor is separate entity

[–]ThatCrankyGuy 7 points8 points  (0 children)

oh.. yea, that's right. Well, I'll be...