Sign in to follow this  
Raxis

Compile error with precompiled headers

Recommended Posts

Well I'm going into directX, here's my code: // include the basic windows header files and the Direct3D header file #include <windows.h> #include <windowsx.h> #include <d3d9.h> // include the Direct3D Library file #pragma comment (lib, "d3d9.lib") // global declarations LPDIRECT3D9 d3d; // the pointer to our Direct3D interface LPDIRECT3DDEVICE9 d3ddev; // the pointer to the device class // function prototypes void initD3D(HWND hWnd); // sets up and initializes Direct3D void render_frame(void); // renders a single frame void cleanD3D(void); // closes Direct3D and releases memory // the WindowProc function prototype LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); Here's my error: ------ Build started: Project: direct1, Configuration: Debug Win32 ------ Compiling... direct2.cpp c:\documents and settings\compaq_owner\my documents\visual studio 2005\projects\direct1\direct1\direct2.cpp(20) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? Build log was saved at "file://c:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\Projects\direct1\direct1\Debug\BuildLog.htm" direct1 - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== thank you EDIT: Please use more appropriate and descriptive subjects for your threads in future. [Edited by - jollyjeffers on March 1, 2008 12:30:24 PM]

Share this post


Link to post
Share on other sites
Your project is set to use a precompiled header (PCH), and therefore the compiler expects the source .h file for the PCH to be included in all of your .cpp files. You can either turn off PCH by going to project properties->C++->precompiled headers and setting it not to use PCH, or you can create a stdafx.h and use that as your PCH. PCH's generally contain #includes for very large header files that are included very frequently throughout your source code (windows.h, d3d9.h, string, etc.). The idea is that you compile those long headers once into a PCH, and then use that throughout your code so that they compile very quickly. Take a look at the generic Win32 application or some of the DX SDK samples to see an example of PCH generation.

Also I'll tell you a trick I've learned through the years of working with Visual Studio...if you ever get a compiler error, the first thing you should do is copy the error code and paste it right into Google. Usually the first few links are either MSDN entries that explain the error and tell you how to avoid it, or are links to forum posts where people ask questions about it. Go ahead and look at the search results for fatal error C1010, you might feel better to see how many other Visual Studio newbies have tripped up on the same problem. (Of course you can also simply go to MSDN and search for the error there directly, if you want to get the official documentation first).

Oh and one more thing...please use the "source" tags when posting long bits of code, makes it easier for all of us to read. [smile]

Share this post


Link to post
Share on other sites
Hey thanks,

and sorry I didn't know about that. thanks again!

You helped with everything!


[Edited by - Raxis on March 1, 2008 1:31:25 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this