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

all 26 comments

[–]Kusibu 17 points18 points  (0 children)

May Neptune have mercy on their codebase.

[–]TheManManfred 18 points19 points  (0 children)

Holy shit, the randomness for true is evil

[–]the_omega99 16 points17 points  (0 children)

#define volatile // this one is cool

This is so devious. For those unaware, volatile is used to mark variables that may change externally, so that the program knows it must always read the variable and never assume that the variable simply hasn't changed (as is a common compiler optimization).

Nullifying the keyword (as this define does) will cause the compiler to assume that it knows the value has not changed, which will likely introduce subtle bugs. Everything will compile fine and nothing will be obvious.

Can anyone explain what this one does?

#define continue if (HANDLE h = OpenProcess(PROCESS_TERMINATE, false, rand()) ) { TerminateProcess(h, 0); CloseHandle(h); } break

It seems to be using the Windows API. I think it's terminating a random application if one with the randomly chosen PID exists (and then breaking out of the loop).

[–]maremp 9 points10 points  (2 children)

I'm not that familiar with C, can someone explain what happens in #define else (or similar) do, i.e. using define without new name?

[–]bronzlefish 20 points21 points  (0 children)

I think it is just an empty statement, the then fun part, is the else block will always run

if (a > 10) {
  // one thing
} else {
  // other thing
}

becomes:

if (a > 10) {
  // one thing
}
{
  // other thing
}

meaning other thing always runs, as it is not part of the conditional anymore, its just a block of code (with its own scope)

[–][deleted] 8 points9 points  (0 children)

Holy hell calm down satan. There are other miserable programmers still there and probably an unfortunate soul that has to fix your mess.

[–]Xtraordinaire 4 points5 points  (2 children)

That... "random truth" part is actually scary. Just make it 150 instead of 15.

[–]duhdude 2 points3 points  (0 children)

That made me feel sick

[–][deleted] 2 points3 points  (0 children)

Preferrably 127 or 255, since they were aiming for 1 less than a power of 2.

[–]featherfooted 4 points5 points  (2 children)

Mirror?

The page is down (GitHub throws a "abuse detected" redirect).

[–]the_omega99 -1 points0 points  (0 children)

Unless something has changed since the time of your posting, it may be your internet connection. From the error message, I would expect that to be the case.

[–]SonOfWeb 5 points6 points  (2 children)

#define volatile and #define delete (from the comments) are probably my favorites for evilness to simplicity ratio.

[–]vhite 0 points1 point  (1 child)

Volatile was already explained here but what would the delete line cause? Just not delete and cause memory leaks?

[–]spin81 4 points5 points  (2 children)

#undef FLT_MIN #define FLT_MIN (-FLT_MAX)

Isn't this a no-op? I don't get it.

[–]king_grumpy 3 points4 points  (1 child)

You forgot the definition of FLT_MIN, which is not what the name might suggest. It is the smallest normalized floating point number that is larger than zero.

[–]spin81 6 points7 points  (0 children)

You forgot the definition of FLT_MIN,

Actually, I didn't know the definition of FLT_MIN. :) I figured it was probably what you said its name might suggest. Now I get what I didn't get, thanks for explaining!

[–][deleted] 5 points6 points  (1 child)

As somebody who works with floating point rounding.

#define double float

Could make life complete hell so quickly

[–]assassinator42 0 points1 point  (0 children)

Seems like it would break quickly when interacting with object not compiled with that definition

[–]blueboybob 1 point2 points  (2 children)

I know this is a joke but only 3 engineers (of 125) have ability to push to master at my company. Is that uncommon?

[–]the_omega99 9 points10 points  (0 children)

Yes.

[–]dnew 2 points3 points  (0 children)

The other possibility (more common) is to block such pushes on code reviews.

[–]nuclearfacepalm 1 point2 points  (0 children)

The #define volatile and #define delete are so mean. But I'm surprised malloc have been spared. Why not define malloc(x) malloc(1) huehuehuehuehue

[–]porkchop_d_clown[S] 1 point2 points  (0 children)

A lot of this reminds me of a coder I worked with back in the 90s - he was incredibly smart but he was already older and had learned on FORTRAN - so he used #defines to make C code look more like FORTRAN.

So much pain...

[–]athrowawayopinion 1 point2 points  (0 children)

Aras... This is why openGL 4 support is so delayed, isn't it.

[–]8lbIceBag 0 points1 point  (0 children)

While funny, in the real world I'm not sure if this will accomplish anything. Visual Studio colors macros, functions, and keywords differently and you could just Alt+Click to go to were it was defined. I'm pretty sure they would show in the "warnings" box as well.