Fix compile error: cannot declare variable in the middle of a function i...

code does not compile with VC2010, because of the "int error" in the middle of a function