Reputation: 1332
I am learning winapi at the beginning from Petzold's book "Programming Windows", 5th edition.
The first example to create a window has a little problem to me. On the book, it's written that
#include "windows.h" (only this one)
But when I use Visual Studio C++ to (under Windows 7 64-bit) compile it, it complains that
Warning 1 warning C4627: '#include "Windows.h"': skipped when looking for precompiled header use
and
Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
After I change it to #include "StdAfx.h"
, it works fine.
So why I can't use Windows.h
, and need to use StdAfx.h
??
Upvotes: 2
Views: 3560
Reputation: 1
In this case you want to change your precompiled headers you are using pch:
Now your problem is solved
Upvotes: -2
Reputation: 54148
You have your project configured to use precompiled headers. In that case you put windows.h
into stdafx.h
, include stdafx.h
in all compilation units that use PCH, and all is well. Or, modify your project settings in the IDE to not use Precompiled Headers.
The book apparently assumes no PCH for clarity and independence from IDE vagaries. Using PCH could speed up your build times if you develop large lists of header files, but for now it's probably simpler to not use this.
Upvotes: 4