Redmine #2573; correct mistake in placement of pragmas

The #pragma is not allowed inside functions, so move it outside.