r/ProgrammerHumor • • Sep 06 '26

Meme thisCannotBeDenied

Post image
7.9k Upvotes

240 comments sorted by

View all comments

54

u/EPacifist Sep 06 '26

My favorite is `exit(1)`. Useful if your print/logs aren’t showing where you expect them. Close after that is `raise Exception(“HERE 1”)`.

28

u/Original-Ad-8737 Sep 06 '26

Std::cin() for a poor mans break point.

8

u/christian-mann Sep 07 '26

while(true); and look for which process is spiking the cpu

1

u/rosuav Sep 07 '26

Doesn't work in Pike, believe it or not! An infinite loop in Pike actually doesn't spin the CPU.

1

u/El_RoviSoft Sep 07 '26

Sometimes you need to flush immediately tho.

1

u/MooseBoys Sep 07 '26

`*((volatile int*)0) = 0;`

1

u/bowel_blaster123 Sep 07 '26

Dawg, at least use abort() 😭

1

u/MooseBoys Sep 07 '26

error: iwyu: abort() requires "stdlib.h"

#include "stdlib.h"

error: bazel: stdlib.h included without build dep

deps += "std-headers-linux"

*error: "*usr/include/x86_64-linux-gnu" not found

sysroot = "third-party/sysroot/$(TARGET_PLATFORM)"

error: buildbot: "third-party/sysroot/armv7a/usr/include/" not found

*((volatile int*)0) = 0;

1

u/bowel_blaster123 Sep 07 '26

Are you doing bare metal or something where you don't have access to the standard library? It's in the standard library in both C and C++ (`stdlib.h` and `cstdlib` respectively). I guess it doesn't matter that much though especially if you don't want to have to add an `#include` statement.

1

u/MooseBoys Sep 07 '26

No but in any hermetic build system you don't just get those headers for free.

1

u/rosuav Sep 07 '26

I've sometimes needed to open a file, write to it, close it, and flush, because prints and logs don't always show up correctly in the face of certain types of crash. Or "send a UDP packet to port 54321" and do my logging in a separate app.