Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

skipped when looking for precompiled header

So some reason, my .cpp file is missing it's header file. But I am not including the header file anywhere else. I just started so I checked all the files I made

enginuity.h

#ifndef _ENGINE_
#define _ENGINE_

class Enginuity
{

public:
    void InitWindow();

};

enginuity.cpp

#include "Enginuity.h"


void Enginuity::InitWindow()
{

}

main.cpp

#include "stdafx.h"
#include "GameProject1.h"

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;                                // current instance
TCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name

// Forward declarations of functions included in this code module:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE, int);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{

code.....
#endif

dont know what's going on. The error I get is

1>c:\users\numerical25\desktop\intro todirectx\gameproject\gameproject1\gameproject1\enginuity.cpp(1) : warning C4627: '#include "Enginuity.h"': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>c:\users\numerical25\desktop\intro todirectx\gameproject\gameproject1\gameproject1\enginuity.cpp(8) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
like image 703
numerical25 Avatar asked May 31 '10 21:05

numerical25


2 Answers

My issue was resolved when i mentioned #include "stdafx.h" on the top of all includes.

like image 153
faizan aslam Avatar answered Sep 21 '22 12:09

faizan aslam


I just experienced this error when including stdafx.h in a cpp file located in a parent folder above where stdafx.h is.

#include "subfolder\stdafx.h"

causes the compile error. Changing it to:

#include "stdafx.h"

fixes the compile error, but then intellisense freaks out.

The "fix" for intellisense, according to someone at Microsoft here, is to add "$(ProjectDir)" (or wherever the stdafx.h is) to the list of directories under Project->Properties->Configuration Propertes->C/C++->General->Additional Include Directories.

I've verified this works in Visual Studio 2012. Should work in 2010 as well.

like image 40
Gordon Glas Avatar answered Sep 17 '22 12:09

Gordon Glas