The problem with VS2013 project in VS2013 arisen, apparently due to the fact that the studio is looking for the first line of #include "stdafx.h" in files like *.cpp , and I need to include another header due to the requirements for cross-platform.

 #ifdef WIN32 #include "stdafx.h" #endif #ifdef __linux__ #include "stdinclude.h" #endif 

Is there any way around this problem?

PS at assembly, in each *.cpp file flashes an error:

 ХХХХ.cpp(3): fatal error C1020: unexpected #endif 

    2 answers 2

    You can also disable precompiled headers (in the same menu as the adjacent answer ), then the requirement that each cpp-file start with #include "stdafx.h" will be gone.

    Note that this will also speed up the re-compilation.


    Visual Studio caches the result of parsing the headers loaded from stdafx.h in a * .pch file. To do this, it requires that the line #include "stdafx.h" be the first of the "meaningful" lines in .cpp. Otherwise, the previous line could, in theory, disable or override something (and this would affect the meaning of the code in stdafx.h ).

    When compiled, Visual Studio discards everything in the file before #include "stdafx.h" , and replaces its state with the contents of * .pch. New versions of Visual Studio should issue at least a warning if there is #include "stdafx.h" before #include "stdafx.h" .

      You can rename the precompiled header in the studio settings:

      C ++ -> Precompiled Headers -> Precompiled Header File

      enter image description here

      • This is not exactly what I had in mind. Then it's easier on other platforms to use the stdafx.h file that was edited for them - Dmitry
      • one
        I thought you would help stdafx.h change to stdinclude.h so that the names were the same under all platforms. - Unick