Why should <stdafx.h> be included first?

    2 answers 2

    stdafx.h should go first only if precompiled headers are included for the translated module; if they are not included, there are no restrictions.

    Why is there any limitation? Because Visual Studio instead of #include "stdafx.h" "inserts" the contents of the PCH file and, accordingly, everything that precedes this line is considered part of the PCH file. Therefore, you can not insert anything before the inclusion of stdafx.h

      I propose to read my article: StdAfx.h . It answers this and other questions related to Precompiled Headers. If you read it, there will no longer be a misunderstanding of how it all works. :)