The Worst C++ Code Ever
Yesterday morning, I overheard a couple co-workers and Cecil talking about problems they were having compiling their software this morning. I popped over to Cecil’s desk to take a look, since I like seeing messed up problems. It took about three seconds flat to diagnose the problem:

It looks like someone has #define’d m_Symbol.
Someone had defined m_Symbol as a preprocessor macro. Why on earth would that be? A bit more digging determined that a co-worker had decided to move a bunch of variables in a library class into a small class, to consolidate them. Unfortunately, this class was written with all of these member variables as public, so he decided that writing a bunch of preprocessor macros would be the only way to allow everyone to keep working despite his changes:
#define m_Symbol m_Sym.m_Type #define m_SymSize m_Sym.m_Size ...
He tested it by building one of our larger applications, and then assumed if it worked there it would work everywhere. This was bad code.
The correct possible solutions involved more work:
- Re-write everyone’s code to use the new classes.
- Use accessor methods and keep data private so that it can be rearranged in the future.
Of course, both of these would involve a lot of code re-writing. An automated semi-intelligent find and replace could take care of at least 80% of the cases, but some hand writing would need to be done. Since it involved more work, he didn’t do it. He plans to someday fix this when he has a spare programmer lying around.
BAH.
Coding everything in Python would be the best alternative.