Lucas Meijer

Game Development Consultancy

28 Jan, 2009

Make sure to have 0 warnings.


Making sure you have 0 warnings is good advice. Unfortunately, I’m not perfect, and in one of my current projects, I have a pretty big list of warnings that I know are not important.
Today, I got bitten by not following the 0 warnings advice. I searched for a bug for over an hour. Let’s see if you can spot the mistake:

if (m_holdingMessages);
{
    Log.Msg("Holding messages in queue");
    msgQueue.Enqueue(msg);
    return true;
}

The if statement always executed. m_holdingMessages should have been false, and I was pretty sure it was false, but the code executed anyway. Being the witty reader of this blog that you are, naturally you immediately spotted the erronous semi-column after the if statement. It got there accidentally, but funny enough the resulting code is valid c#. It’s silly c#, but valid.

Naturally, Visual Studio, (and Unity) give warnings when compiling this. They say: “Possibly mistaken empty statement”. Dead on.

But I missed the warning, because it drowned in all those warnings I had been ignoring all that time.
Had I been a good boy, I would have made sure I had no warnings at all, and this one waring would have gotten my attention, and I could have spent my morning drinking coffees instead of looking for this silly bug.

Tags:

1 Response to "Make sure to have 0 warnings."

1 | Emil Johansen (AngryAnt)

January 28th, 2009 at 2:46 pm

Avatar

Nice one! :D

Perhaps you should do an editor script scanning for warnings not on your “ok to ignore” list eh? Questions is will it be quicker than fixing those warnings? ;)

Comment Form

Game Development Consultancy

Hi. I'm Lucas Meijer. consultant on game development projects I work at Unity. You're looking at my portfolio website.

Please look around, and take a look at my work, my thoughts or more general information about myself.


If you have any questions regarding consulting, licensing of games, or anything else, feel free to email me at lucas@lucasmeijer.com

Contact Info

Lucas Meijer
lucas@lucasmeijer.com
lucasmeijer on twitter
ljmeijer on skype