If your project is set to use precompiled headers, the precompiled header must be THE VERY FIRST THING in the file. Only comments can be before it, nothing else.
Solutions:
1) don't use precompiled headers
2) #include your precompiled header first
In VS, unless you specifically state you want an empty project, it will often default to using precompiled headers, so you need to #include "stdafx.h" first.