Fixed the build on MSVC.

Local variables need to be declared at the start of the block.