Visual studio ошибка c1010

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Learn more about: Fatal Error C1010

Fatal Error C1010

09/03/2019

C1010

C1010

dfd035f1-a7a2-40bc-bc92-dc4d7f456767

Fatal Error C1010

unexpected end of file while looking for precompiled header. Did you forget to add ‘#include name‘ to your source?

Remarks

An include file specified by /Yu isn’t listed in the source file. This option is enabled by default in many Visual Studio C++ project types. The default include file specified by this option is pch.h, or stdafx.h in Visual Studio 2017 and earlier.

In the Visual Studio environment, use one of the following methods to resolve this error:

  • Make sure you haven’t inadvertently deleted, renamed, or removed the pch.h header file or pch.cpp source file from the current project. (In older projects, these files may be named stdafx.h and stdafx.cpp.)

  • Make sure the pch.h or stdafx.h header file is included before any other code or preprocessor directives in your source files. (In Visual Studio, this header file is specified by the Precompiled Header File project property.)

  • You can turn off precompiled header use. If you turn off precompiled headers, it may severely impact build performance.

To turn off precompiled headers

To turn off precompiled header use in a project, follow these steps:

  1. In the Solution Explorer window, right-click the project name, and then choose Properties to open the project Property Pages dialog.

  2. In the Configuration drop-down, select All Configurations.

  3. Select the Configuration properties > C/C++ > Precompiled Headers property page.

  4. In the property list, select the drop-down for the Precompiled Header property, and then choose Not Using Precompiled Headers. Choose OK to save your changes.

  5. In the Solution Explorer window, right-click the pch.cpp source file in your project. (In older projects, the file may be named stdafx.cpp.) Choose Exclude from Project to remove it from the build.

  6. Use the Build > Clean solution menu command for each configuration you build, to delete any project_name.pch files in your intermediate build directories.

See also

Precompiled header files
/Yc (Create precompiled header file)
/Yu (Use precompiled header file)

I compile the following code but I get a compile error in Visual Studio that I cannot understand.

#include <iostream>

using namespace std;

int main()
{
    int matchCount, findResult;
    long childPID;
    string userInput = "blank";

    // string to be searched through
    string longString = "The PPSh-41 is a Soviet submachine gun designed by Georgi Shpagin as an inexpensive, simplified alternative to the PPD-40.";

    while (userInput.compare("!wq"));
    {
        // reset variables for reuse
        matchCount = 0;
        findResult = -1;

        cout << "Please enter a word/s to search for (!wq to exit): "; // prompts user for string to search for
        cin >> userInput; // takes user input

        if (userInput.compare("!wq")) // checks user input to see if they still wish to search for a string
        {
            childPID = fork();

            if (childPID == 0)
            {
                while (findResult < longString.length)
                {
                    findResult = longString.find(userInput, findResult + 1, userInput.length);

                    if (findResult < longString.length)
                        matchCount++;
                }

                cout << "There are " << matchCount << " instances of " << userInput << " in longString." << endl;
            }
            else
                cout << "childPID != 0" << endl;
        }
        else
            cout << "User has chosen to exit. Exiting." << endl;
    }

    return 0;
}

The error reads:

«wordcount.cpp(57) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include «stdafx.h»‘ to your source?»

I don’t believe I need a header file to run this code. Thank you for all your help in advance.

Glenn Teitelbaum's user avatar

asked Nov 21, 2013 at 5:35

user1800967's user avatar

5

Look at https://stackoverflow.com/a/4726838/2963099

Turn off pre compiled headers:

Project Properties -> C++ -> Precompiled Headers

set Precompiled Header to "Not Using Precompiled Header".

Community's user avatar

answered Nov 21, 2013 at 5:47

Glenn Teitelbaum's user avatar

Glenn TeitelbaumGlenn Teitelbaum

10k3 gold badges36 silver badges80 bronze badges

3

The first line of every source file of your project must be the following:

#include <stdafx.h>

Visit here to understand Precompiled Headers

answered Nov 21, 2013 at 5:48

asif's user avatar

asifasif

9758 silver badges16 bronze badges

4

Create a new «Empty Project» , Add your Cpp file to the new project, delete the line that includes stdafx.

Done.

The project no longer needs the stdafx. It is added automatically when you create projects with installed templates.
enter image description here

answered Apr 22, 2014 at 2:26

Zahid Rouf's user avatar

Zahid RoufZahid Rouf

1,5912 gold badges11 silver badges10 bronze badges

1

RRS feed

  • Remove From My Forums
  • Question

  • fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include «stdafx.h»‘ to your source?

    I am using Visual Studio 2005 Academic Edition.

    I clicked «Tool»=>Options=>Debugging=>Edit and Continue.

    Let «Allow precomping» unchecked then.

    Why does this error occury?

    Thanks! 

Answers

  • «Did you forget to add #include «stdafx.h» to your source»?

All replies

  • «Did you forget to add #include «stdafx.h» to your source»?

  • I have generated source code and was trying to compile in release mode (instead of debug).  I got this error.  Putting in the #include «stdafx.h» does not fix the problem.  Anyone know what is going on and why I am getting this error in Release mode and not in Debug mode?

  • I figured out what the problem was.  The entire project needed to be marked as ‘Not Using Precompiled Headers’ in the property pages.  This is under the ‘Configuration Properties’->C/C++->’Precompiled Headers’.  You could just single out the one file if you wanted to also.

    I then was getting some linker unresolved external errors after doing that.  Make sure you also check for any libraries that need to be linked against.  I had (NOINHERIT) in my Additional Dependencies field of the properties.  That field is under the ‘Configuration Properties’->Linker->Input.

    Just wanted to put on the board what I found in case anyone else has these easy setup issues.  These things are different from what I am used to or at least in different places.

    • Proposed as answer by

      Friday, October 7, 2011 7:40 PM

  • Where is

    ‘Configuration Properties’?

    Thanks

    • Proposed as answer by
      Prizzy29
      Monday, October 26, 2009 7:27 AM

  •  The Steve340 wrote:

    I have generated source code and was trying to compile in release mode (instead of debug).  I got this error.  Putting in the #include «stdafx.h» does not fix the problem.  Anyone know what is going on and why I am getting this error in Release mode and not in Debug mode?


  • Once the C++ is open in a project = Tools/options/”edit/countine” you click on the left side / and then close to the bottom is the option to add or remove ‘Precompiled Headers’

    I had an issue, where there ‘Precompiled Headers’ came out of no where, I didn’t even chose it but, I googled the issue and came up with the site. An I read the idea’s on here an searched for it in C++ search and it told me how to do. An I thought I would share the little info.

    • Proposed as answer by
      SANJAY KHACHANE
      Wednesday, June 6, 2012 10:58 AM
    • Unproposed as answer by
      SANJAY KHACHANE
      Wednesday, June 6, 2012 10:59 AM
    • Proposed as answer by
      SANJAY KHACHANE
      Wednesday, June 6, 2012 10:59 AM

  • Go To 

    I am using Visual Studio 2010.

    Clicked New Project —> Visual C++ —> Win32 Console Application —>

    Enter Name Of Application—> Click Ok

    Show «Win32 Application Wizard» — > Click Next —>

    In Scrine Show 

    Additional options: 

    Empty project 
    Export symbols 
    Precompiled header 

    Untick Precompiled Header

    then Finished It

    • Edited by
      SANJAY KHACHANE
      Wednesday, June 6, 2012 11:08 AM

  • Hi..ardmore,

    I was having same problem, but solved it by following manner..

    Open property of that particular page and  go to confi. Property -> c/c++ -> precompiled headers -> set this value to “Not using precompiled Headers”

    • Edited by
      Mayur.Dabhi
      Thursday, September 20, 2012 11:06 AM

  • Thank you soo much.. its works fine steve


I have a project, originally developed on Microsoft Visual C++ . NET, Version 7.0.9466 and it works very well. I tried to use MS 2013 to run my project, and when I try to build the project, I have this error menssage:

error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include «stdafx.h»‘ to your source?

Some actions that I already did:

  • I Selected the option «Use(/Yu)» on Precompiled Header in PropertyPages-> C/C++ -> Precompiled Header
  • I Set the Precompiled Header File to stdafx.h
  • I put #include "stdafx.h" at the beginning of the .cpp file
  • I had to change #include "stdafx.h" to #include "../stdafx.h" because I had this error message:

IntelliSense: cannot open source file «stdafx.h»

Here is the .cpp file where I have this message error

#include "../stdafx.h"
#include "timedmsgbox.h"

/////////////////////////////////////////////////////////////////////////
//
// CDlgTimedMessageBox
//
/////////////////////////////////////////////////////////////////////////

CMapPtrToPtr		CDlgTimedMessageBox::m_mapTimerIdToClassMe;
CCriticalSection	CDlgTimedMessageBox::m_sectMap;
extern BOOL AFXAPI AfxIsDescendant(HWND hWndParent, HWND hWndChild);

// the static one to call the messagebox with one line
UINT CDlgTimedMessageBox::TimedMessageBox(UINT flags, LPCTSTR ptszMessage, LPCTSTR ptszTitle, 
						DWORD dwTimeout, UINT dDefaultReturn,
						LPCTSTR ptszMessageTimer, HWND hwndParent, BOOL *pbStoppedByUser)
{
	CDlgTimedMessageBox		msgBox(flags, ptszMessage, ptszTitle, 
									dwTimeout, dDefaultReturn, 
									ptszMessageTimer, hwndParent);

	return msgBox.ShowMessageBox(pbStoppedByUser);
}

CDlgTimedMessageBox::CDlgTimedMessageBox(UINT flags, 
								LPCTSTR ptszMessage, LPCTSTR ptszTitle, 
								DWORD dwTimeout, UINT dDefaultReturn,
								LPCTSTR ptszMessageTimer, 
								HWND hwndParent)
{
	m_hParent			= hwndParent;
	m_Message			= ptszMessage;
	m_Title				= ptszTitle;
	m_flags				= flags;
	m_dwTimeout			= dwTimeout-1;
	m_MessageTimer		= ptszMessageTimer;
	m_DefaultReturn		= dDefaultReturn;
	
	m_hMsgBox			= NULL;
	m_hStaticText		= NULL;
	m_hDefaultButton	= NULL;
	m_bRunning			= FALSE;
	m_bStoppedByTimer	= FALSE;

	if( !m_hParent )
	{
		CWnd *m_pParent = AfxGetApp()->GetMainWnd();
		m_hParent = m_pParent->m_hWnd;
	}
}

CDlgTimedMessageBox::~CDlgTimedMessageBox()
{
}

#pragma warning( push)
#pragma warning (disable : 4312) // conversion to type of greater size
UINT CDlgTimedMessageBox::ShowMessageBox(BOOL *pbStoppedByUser)
{
	// start timer 
	CDlgTimedMessageBox::m_sectMap.Lock();
	{
		m_idTimer = (UINT)::SetTimer(NULL, 0, 1000, (TIMERPROC) CDlgTimedMessageBox::GlobalTimerProc);
		CDlgTimedMessageBox::m_mapTimerIdToClassMe.SetAt((void*)m_idTimer, this);
	}
	CDlgTimedMessageBox::m_sectMap.Unlock();
	
	// show MessageBox
	m_bRunning = TRUE;
	m_dwStarted = ::GetTickCount();
	
	m_CurrentMessage = m_Message;
	if( !m_MessageTimer.IsEmpty() )
	{
		CString	second;
		second.Format(m_MessageTimer, (m_dwTimeout+1)/1000);
		m_CurrentMessage.Format("%s%s", m_Message, second);
	}
	UINT erg = ::MessageBox(m_hParent, m_CurrentMessage, m_Title, m_flags);
	m_bRunning = FALSE;

	CDlgTimedMessageBox::m_sectMap.Lock();
	{
		::KillTimer(NULL, m_idTimer);
		m_idTimer = 0;
		CDlgTimedMessageBox::m_mapTimerIdToClassMe.RemoveKey((void*)m_idTimer);
	}
	CDlgTimedMessageBox::m_sectMap.Unlock();

	if( pbStoppedByUser )
		*pbStoppedByUser = !m_bStoppedByTimer;
	
	return erg;
}
#pragma warning( pop )

void CALLBACK CDlgTimedMessageBox::GlobalTimerProc(HWND hwnd, UINT uiMsg, UINT_PTR idEvent, DWORD dwTime)
{
	//TRACE("Global timer with id=%un", idEvent);
	
	CDlgTimedMessageBox	*pMe = NULL;
	
	// Find the corresponding class by the timer-id
	CDlgTimedMessageBox::m_sectMap.Lock();
	{
		CDlgTimedMessageBox::m_mapTimerIdToClassMe.Lookup((void*)idEvent, (void *&) pMe);
	}	
	CDlgTimedMessageBox::m_sectMap.Unlock();
	
	if( pMe!=NULL )
		pMe->LocalTimerProc();
}

void CDlgTimedMessageBox::LocalTimerProc(void)
{
	//TRACE("Local timer with id=%u (%s)n", m_idTimer, m_Title);

	if( !m_bRunning )
		return;

	// lookup the handles 
	GetWindowHandles();


	if( !m_hStaticText || !m_hMsgBox )
		return;

	DWORD now = GetTickCount()-m_dwStarted;
	
	if( now >= (m_dwTimeout) )
	{
		// done with the box
		m_bStoppedByTimer = TRUE;
		::PostMessage(m_hMsgBox, WM_COMMAND, (WPARAM) m_DefaultReturn, (LPARAM) m_hDefaultButton);
	}
	else
	{
		m_CurrentMessage = m_Message;
	
		// not done: set text again
		if( !m_MessageTimer.IsEmpty() )
		{
			CString	second;
			second.Format(m_MessageTimer, (100+m_dwTimeout-now)/1000);
			m_CurrentMessage.Format("%s%s", m_Message, second);
		}
		::SetWindowText(m_hStaticText, m_CurrentMessage);
	}	
}

void CDlgTimedMessageBox::GetWindowHandles(void)
{
	HWND		hWnd;
	CWnd		*pWnd;
	CString		title;
	CPtrList	allButtons;

	//
	// Handle of the messageBox
	//
	if( !m_hMsgBox )
	{
		hWnd = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
		while( (hWnd!=NULL) && (m_hMsgBox==NULL) )
		{
			pWnd = CWnd::FromHandle(hWnd);
			pWnd->GetWindowText(title);

			if( AfxIsDescendant(m_hParent, hWnd) && ::IsWindowVisible(hWnd) && (m_Title.CompareNoCase(title)==0) )
			{
				m_hMsgBox = hWnd;
				break;
			}
			
			hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
		}
	}

	//
	// Handle of the static text
	// TODO only if text-replace is needed
	//
	if( m_hMsgBox && !m_hStaticText )
	{
		// not sure if this will work always
		// under Win2000 it did
		//m_hStaticText = ::GetDlgItem(m_hMsgBox, 0xFFFF);

		// not sure, so lets find it dynamically!

		char		className[_MAX_PATH];
		CString		classNameOk("STATIC");
		LONG		id;

		hWnd = ::GetWindow(m_hMsgBox, GW_CHILD);
		while( (hWnd!=NULL) && (m_hStaticText==NULL) )
		{
			id = ::GetWindowLong(hWnd, GWL_ID);
			
			// small ids only for buttons
			if( id > IDHELP )
			{
				if( ::GetClassName(hWnd, className, _MAX_PATH) )
				{

					// looking only for a static 
					if( classNameOk.CompareNoCase(className) == 0 )
					{
						// not check the text
						pWnd = CWnd::FromHandle(hWnd);
						pWnd->GetWindowText(title);
						
						if( m_CurrentMessage.CompareNoCase(title) == 0 )
						{
							m_hStaticText = hWnd;
							break;
						}

					}
				}
			}
			else
			{
				allButtons.AddTail(hWnd);
			}

			hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
		}

	}

	//
	// Handle of the default button
	//
	if( m_hMsgBox && !m_hDefaultButton )
	{
		m_hDefaultButton = ::GetDlgItem(m_hMsgBox, m_DefaultReturn);
		
		// Problem: 
		// if generated with MB_OK the button has NOT IDOK, but IDCANCEL !!
		// then lets take the first button we find !
		// (with and IDCANCEL this works, because it is the only button
		// if this problem encounters also with 2 buttons, I have no chance 
		// to find out which one is the better one!)
		while( allButtons.GetCount()>0 && !m_hDefaultButton )
		{
			m_hDefaultButton = (HWND) allButtons.GetHead();
			allButtons.RemoveHead();
			
			if( m_hDefaultButton )
				m_DefaultReturn = ::GetWindowLong(m_hDefaultButton, GWL_ID);
		}
	}
}

and here is the stdafx.h file

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#pragma once

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
//#define WINVER 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#define WINVER 0x0602       // SMS2014XXXX alteração para funcionar windows 8
#endif

#ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
//#define _WIN32_WINNT 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#define _WIN32_WINNT 0x0602       // SMS2014XXXX alteração para funcionar windows 8
#endif						

#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400	// Change this to the appropriate value to target IE 5.0 or later.
#endif

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS	// some CString constructors will be explicit

// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls

#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <afxdhtml.h>

I am new on visual studio and I have no ideia what’s is wrong on all of this. Someone could help me with it?

Speed up your PC in just a few clicks

  • 1. Download and install ASR Pro
  • 2. Open the application and click on the Scan button
  • 3. Select the files or folders you want to restore and click on the Restore button
  • Download this software now and say goodbye to your computer problems.

    Sometimes your computer may give you a c1010 Visual Studio error message. There can be many reasons for this problem. When someone creates a new project that exists in Visual Studio, they manually create a precompiled header file called pch. added to the project. pre-compiled h2 tags are only compiled if they, and even the files they contain, are new. If you only make changes to the project’s source code, your amplification skips compilation, which usually uses a precompiled header.

    How do I get rid of PCH h in Visual Studio?

    Open your projectThen select “Project” “Application Name > Properties…”. Expand Configuration Properties > > c/c++ Precompiled Headers. Set the Precompiled Header option to Do not use precompiled headers.

    When I compile the following code, I get a compilation error in Visual Studio that I don’t understand.

    #include by standard with namespace;interior()    match interval, find result;   long ChildPID;    field userInput = "empty";    // search string    longString sequence = "PPSh-41 is a Soviet submachine gun designed by Georgy Shpagin as a natural, simplified and cheap PPD-40." ;   anyway (userInput.compare("!wq"));            // Reset variables to reuse them        number of matches = 0;        the search result is -1;        cout << "Please enter one or more search words To (!wq Exit): "; // ask the person to find the string        cin >> user input; // Accept input from male or female        if (userInput.compare("!wq")) // The bank checks the user input to see if there are manyDoes anyone else want to search for the real string                    childPID = fork();           While (childPID == 0)                            and (findResult < longString.length)                                    = findResult longString.find(userInput, findResult + UserInput 1,.length);                    in the case where (findResult < longString.length)                        number of matches++;                                cout << "Definitely there will be " << matchCount << ' instances of " << userInput << in longString." << end;                        different                cout << "childPID ! means 0" << endl;                different            cout << "The user has chosen to exit the program. Quit.<< " endl;     Returns 0;

    error c1010 visual studio

    «wordcount.cpp(57): Fatal error Shocking c1010: Looking for precompiled header at end of file. Forgot to include ‘#include «stdafx.h»‘ in source code?

    Did you forget to add Stdafx H to your source?

    Did you forget to include ‘#include «stdafx»? in your source? The fact that you are getting this type of error means that you are sure about this «Win32 Application Helper» (Visual Studio 2015) or possibly the «Windows Desktop Helper» (Visual Studio 2017).

    I don’t think I need an h2 tag file to run this code. Thanks in advance for your efforts.

    Read More:

    Fatal error C1010: Unexpected end of file found while searching for precompiled headers. Did you «#include», forgot to add stdafx.h to the code?
    Source Error Parsing:
    The above error occurs because compilers mostly look for prefixes.But the compiled sensor header (#include «stdafx.If h default»), the file definitely does not complete properly. Header file «stdafx.h» found in precompiled non-instructions.
    project (because the specific CPP point file uses a precompiled header (/YU) by default, add third-party documents that # contain precompiled «stdafx.h» directives, for this reason the compiler in the CPP file is not found at all until the end)
    My problem when it came up was adding files containing large un tuo des to MFC. Hand. RPC folder. These .h and .cpp computer data files belong to the standard category of Adaptive C++ source code and have a closer relationship to MFC.
    Resolution: A.

    error c1010 visual studio

    1) Solution Explorer, available by right-clicking on the corresponding one. CPP file, «Properties» visitor
    2) on the retrieved page in the configuration properties check PM «C/C++», to «Precompiled Header»
    3) change to the right of the first line of the option «create/use precompiled title» changed from previously «use comsawed header (/w)» to «do not use precompiled header» 4)
    Note: second
    .
    (not recommended)
    About 1) solution, right-click on the project itself, select «Properties»
    2) Go back to C/c++ configuration properties -> -> Change «Use precompiled (/YU)» headers should not apply «very precompiled header»

    Download this software now and say goodbye to your computer problems.

    Oshibka C1010 Vizualnaya Studiya
    Erreur C1010 Studio Visuel
    Error C1010 Estudio Visual
    Fel C1010 Visual Studio
    Fout C1010 Visuele Studio
    Erro C1010 Visual Studio
    Blad C1010 Studio Wizualne
    Errore C1010 Visual Studio
    Fehler C1010 Visual Studio
    오류 C1010 비주얼 스튜디오

    Harrison Crist

    Возможно, вам также будет интересно:

  • Visual studio ошибка 1168
  • Visual studio окно ошибок как открыть
  • Visual studio не подчеркивает ошибки
  • Visual studio как отключить ошибку
  • Visual studio как включить отображение ошибок

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии