The Final Warning
2/Jul 2008
Recently I’ve been playing with SQLite for my new experiment (more about it later, when I’m done). It’s one sweet little library, integrating it and coding a quick C++ wrapper took me maybe 1 hour. As authors claim themselves - it just works. I’ve only one tiny complaint, though. As I mentioned before, all my home projects are compiled with maximum warning level and warnings treated as errors. Sadly, this seems to break roughly 50% of external libraries, including SQLite (trying to compile sqlite3.c gives me ~400 warnings, mainly about conversions and unused variables). If there are few only few warnings, I’ll try to correct them, if there’s more, I just give up and lower level/treating warnings as errors for this particular file. I try to avoid this if possible, because in my experience every little bit of compile time diagnostics matters. Sure, MSVC warning level 4 may not be Lint equivalent, but in some cases it lets you find mistakes that normally would require some debugging (some people hate ‘unused variable’ warning, surprisingly, it’s my favourite one). Of course, I’m not the first one to appreciate the usefulness this setting. Noel Llopis has been advocating it for ages (only found the latest mention, but there are more). I’ve yet to work in a company that maintains such policy successfully, however. Sure, there are more excuses (more external libraries, megabytes of legacy code, more coders and so on), but still it’s a little bit like the fact that Pierre observed. It’s weird that code that we produce in our free time may end in better shape than the code produced within a company.
PS. I’m more and more convinced that C is better for reusable, public libraries (like SQLite) than C++. I’m not sure why, but interfaces just “feel” tighter.
Old comments
ed 2008-07-06 21:52:23
It’s even more frightening when your compiler doesn’t tell you if something is wrong with the code. I have a code to some huge game that compiles under VS2005 with Xbox360 target without any problems. The same code under VS2005 with Win32 target reports about 20 possible problems (few possible divisions by zero, few possible “out of array” accesses etc).
js 2008-07-07 10:13:52
An issue lost in an ocean of warnings
will cost production lot of sterlings