https://stackoverflow.com/questions/652788/what-is-the-worst-real-world-macros-pre-processor-abuse-youve-ever-come-across
What is the worst real-world macros/pre-processor abuse you’ve ever come across?
From memory, it looked something like this:
#define RETURN(result) return (result);}
int myfunction1(args) {
int x = 0;
// do something
RETURN(x)
int myfunction2(args) {
int y = 0;
// do something
RETURN(y)
int myfunction3(args) {
int z = 0;
// do something
RETURN(z)
Yes that’s right, no closing braces in any of the functions. Syntax highlighting was a mess, so he used vi to edit (not vim, it has syntax coloring!)
He was a Russian programmer who had mostly worked in assembly language. He was fanatical about saving as many bytes as possible because he had previously worked on systems with very limited memory. “It was for satellite. Only very few byte, so we use each byte over for many things.” (bit fiddling, reusing machine instruction bytes for their numeric values) When I tried to find out what kinds of satellites, I was only able to get “Orbiting satellite. For making to orbit.”
He had two other quirks: A convex mirror mounted above his monitor “For knowing who is watching”, and an occasional sudden exit from his chair to do a quick ten pushups. He explained this last one as “Compiler found error in code. This is punishment”.