Permalink
Cannot retrieve contributors at this time
| 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 |
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:
-
In the Solution Explorer window, right-click the project name, and then choose Properties to open the project Property Pages dialog.
-
In the Configuration drop-down, select All Configurations.
-
Select the Configuration properties > C/C++ > Precompiled Headers property page.
-
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.
-
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.
-
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.
asked Nov 21, 2013 at 5:35
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".
answered Nov 21, 2013 at 5:47
Glenn TeitelbaumGlenn Teitelbaum
9,9583 gold badges35 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
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.
answered Apr 22, 2014 at 2:26
Zahid RoufZahid Rouf
1,5712 gold badges11 silver badges10 bronze badges
1
Put this at every source file of your project at the top
#include <stdafx.h>
or / and
Your .cpp file is probably not in the same directory as pch.h
answered Aug 13, 2021 at 23:08
deanqxdeanqx
111 silver badge4 bronze badges
Содержание
- Неустранимая ошибка C1010
- Комментарии
- Отключение предкомпилированных заголовков
- Fatal Error C1010
- Remarks
- To turn off precompiled headers
- Fatal error c1010 это
- Answered by:
- Question
- Answers
- All replies
- Name already in use
- cpp-docs / docs / error-messages / compiler-errors-1 / fatal-error-c1010.md
- Fatal error c1010 это
- Answered by:
- Question
- Answers
- All replies
Неустранимая ошибка C1010
непредвиденный конец файла при поиске предкомпилированного заголовка. Вы забыли добавить имя #include в источник?
Комментарии
Включаемый файл, указанный параметром /Yu , не указан в исходном файле. Этот параметр включен по умолчанию во многих типах проектов Visual Studio C++. Файл включения по умолчанию, заданный этим параметром, — pch.h или stdafx.h в Visual Studio 2017 и более ранних версиях.
В среде Visual Studio используйте один из следующих методов для устранения этой ошибки:
Убедитесь, что вы не случайно удалили, не переименовали или не удалили файл заголовка pch.h или исходный файл pch.cpp из текущего проекта. (В более старых проектах эти файлы могут называться stdafx.h и stdafx.cpp.)
Убедитесь, что файл заголовка pch.h или stdafx.h включен перед любым другим кодом или директивами препроцессора в исходных файлах. (В Visual Studio этот файл заголовка задается свойством проекта предварительно скомпилированного файла заголовка .)
Вы можете отключить использование предкомпилированного заголовка. Отключение предкомпилированных заголовков может серьезно повлиять на производительность сборки.
Отключение предкомпилированных заголовков
Чтобы отключить использование предкомпилированного заголовка в проекте, выполните следующие действия.
В окне Обозреватель решений щелкните правой кнопкой мыши имя проекта и выберите пункт Свойства, чтобы открыть диалоговое окно Страницы свойств проекта.
В раскрывающемся списке Конфигурация выберите Все конфигурации.
Выберите страницу свойств Свойства> конфигурацииC/C++>Предкомпилированные заголовки.
В списке свойств выберите раскрывающийся список для свойства Precompiled Header (Предкомпилированные заголовки ), а затем выберите Не использовать предкомпилированные заголовки. Выберите ОК для сохранения внесенных изменений.
Источник
Fatal Error C1010
unexpected end of file while looking for precompiled header. Did you forget to add ‘#include name‘ to your source?
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 header use in a project, follow these steps:
In the Solution Explorer window, right-click the project name, and then choose Properties to open the project Property Pages dialog.
In the Configuration drop-down, select All Configurations.
Select the Configuration properties > C/C++ > Precompiled Headers property page.
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.
Источник
Fatal error c1010 это
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
i included an vb dll into vc++. When i compiled i am getting this error.
fatal error C1010: unexpected end of file while looking for precompiled header directive in the .c file produced from the idl file.
i included comdef.h and header file produced by midl compiler to the source file. i had the dll file in the same directory of vc++ project folder. Any thing need to be set here ?
Answers
Produced from the idl file? Thats not possible.
You defined your project to use precompiled header files. So your c file or cpp files must include the file that is defined for precompilation at the top of it.
Usually #include «stdafx.h» must be placed into your cpp file.
If you want to include the c file created form the idl. You can either include it into obne of your files, or you remove the options to use precompiled headers for this specific source file.
Thank you Mr. Martin,
Now i got after setting the precompiled headers off.
It is in Project-> Settings->C/C++->Category->Precompiled headers->not using precompiled headers. Thanks once again.
Produced from the idl file? Thats not possible.
You defined your project to use precompiled header files. So your c file or cpp files must include the file that is defined for precompilation at the top of it.
Usually #include «stdafx.h» must be placed into your cpp file.
If you want to include the c file created form the idl. You can either include it into obne of your files, or you remove the options to use precompiled headers for this specific source file.
Thank you Mr. Martin,
Now i got after setting the precompiled headers off.
It is in Project-> Settings->C/C++->Category->Precompiled headers->not using precompiled headers. Thanks once again.
Hi, I’m a beginer to VC++. I wrote the following code. When compils it it shows «fatal error C1010: unexpected end of file while looking for precompiled header directive». when I included the stdafx.h it shows 3 erros where as 1 before. I tried all the headerfile setting under project->settings->c/c++,but it doesnot work. I’m using visual studio 6.0. Sir please help me.
Thanks in advance.
int_stdcall WinMain(
HINSTANCE hInstancs,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
<
MessageBox(0,»Hello»,»Hello»,0);
return(0);
>
Источник
Name already in use
cpp-docs / docs / error-messages / compiler-errors-1 / fatal-error-c1010.md
- Go to file T
- Go to line L
- Copy path
- Copy permalink
Copy raw contents
Copy raw contents
Fatal Error C1010
unexpected end of file while looking for precompiled header. Did you forget to add ‘#include name‘ to your source?
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:
In the Solution Explorer window, right-click the project name, and then choose Properties to open the project Property Pages dialog.
In the Configuration drop-down, select All Configurations.
Select the Configuration properties > C/C++ > Precompiled Headers property page.
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.
Источник
Fatal error c1010 это
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
i included an vb dll into vc++. When i compiled i am getting this error.
fatal error C1010: unexpected end of file while looking for precompiled header directive in the .c file produced from the idl file.
i included comdef.h and header file produced by midl compiler to the source file. i had the dll file in the same directory of vc++ project folder. Any thing need to be set here ?
Answers
Produced from the idl file? Thats not possible.
You defined your project to use precompiled header files. So your c file or cpp files must include the file that is defined for precompilation at the top of it.
Usually #include «stdafx.h» must be placed into your cpp file.
If you want to include the c file created form the idl. You can either include it into obne of your files, or you remove the options to use precompiled headers for this specific source file.
Thank you Mr. Martin,
Now i got after setting the precompiled headers off.
It is in Project-> Settings->C/C++->Category->Precompiled headers->not using precompiled headers. Thanks once again.
Produced from the idl file? Thats not possible.
You defined your project to use precompiled header files. So your c file or cpp files must include the file that is defined for precompilation at the top of it.
Usually #include «stdafx.h» must be placed into your cpp file.
If you want to include the c file created form the idl. You can either include it into obne of your files, or you remove the options to use precompiled headers for this specific source file.
Thank you Mr. Martin,
Now i got after setting the precompiled headers off.
It is in Project-> Settings->C/C++->Category->Precompiled headers->not using precompiled headers. Thanks once again.
Hi, I’m a beginer to VC++. I wrote the following code. When compils it it shows «fatal error C1010: unexpected end of file while looking for precompiled header directive». when I included the stdafx.h it shows 3 erros where as 1 before. I tried all the headerfile setting under project->settings->c/c++,but it doesnot work. I’m using visual studio 6.0. Sir please help me.
Thanks in advance.
int_stdcall WinMain(
HINSTANCE hInstancs,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
<
MessageBox(0,»Hello»,»Hello»,0);
return(0);
>
Источник
|
Evgen311293 57 / 57 / 3 Регистрация: 23.03.2011 Сообщений: 567 Записей в блоге: 3 |
||||
|
1 |
||||
|
27.07.2013, 23:07. Показов 9109. Ответов 22 Метки нет (Все метки)
Начал изучать С++, написал пример программы, но когда я ее хочу скомпилировать, то выдает оишбку: Вот сам код:
__________________
0 |
|
Nikitko_Cent 147 / 117 / 37 Регистрация: 27.10.2011 Сообщений: 690 |
||||||||
|
27.07.2013, 23:09 |
2 |
|||||||
|
В ошибке же всё подробно объясняется — добавь
Перед всеми добавленными директивами Т.е., в твоём случае, код будет такой:
0 |
|
Evgen311293 57 / 57 / 3 Регистрация: 23.03.2011 Сообщений: 567 Записей в блоге: 3 |
||||
|
27.07.2013, 23:25 [ТС] |
3 |
|||
|
А что он дает? просто я до него не дошел и ничего пока сказано о нем не было Добавлено через 2 минуты
В ошибке же всё подробно объясняется — добавь
после добавления этого, появились другие две ошибки: 2. Ошибка 2 error LNK1120: 1 неразрешенных внешних элементов F:Программы на С++first_programmfirst_programmDebugfirst_prog ramm.exe first_programm
0 |
|
101 / 88 / 7 Регистрация: 17.12.2010 Сообщений: 416 |
|
|
27.07.2013, 23:29 |
4 |
|
первая ошибка исчезла у меня после исправления в проект-свойства-компоновщик-свойства конфигурации-система -подсистема на Консоль /subsystem:console. быть может и вам поможет. =)
0 |
|
57 / 57 / 3 Регистрация: 23.03.2011 Сообщений: 567 Записей в блоге: 3 |
|
|
27.07.2013, 23:33 [ТС] |
5 |
|
свойства конфигурации не могу найти это в компоновщике
0 |
|
101 / 88 / 7 Регистрация: 17.12.2010 Сообщений: 416 |
|
|
27.07.2013, 23:40 |
6 |
|
компоновщик->система->подсистема и там первая строка
0 |
|
Сгибальщик 42 / 42 / 4 Регистрация: 18.05.2013 Сообщений: 220 |
|
|
27.07.2013, 23:43 |
7 |
|
Проще создавать пустой проект и не париться с предкомпилированным заголовком.
0 |
|
57 / 57 / 3 Регистрация: 23.03.2011 Сообщений: 567 Записей в блоге: 3 |
|
|
28.07.2013, 00:07 [ТС] |
8 |
|
так я вроде бы просто и создал Добавлено через 25 секунд
Проще создавать пустой проект как его еще проще создать? Добавлено через 10 минут
0 |
|
5493 / 4888 / 831 Регистрация: 04.06.2011 Сообщений: 13,587 |
|
|
28.07.2013, 00:09 |
9 |
|
так я вроде бы просто и создал Так создавали: Создать проект — Общие — Пустой ?
0 |
|
Сгибальщик 42 / 42 / 4 Регистрация: 18.05.2013 Сообщений: 220 |
|
|
28.07.2013, 00:20 |
10 |
|
Evgen311293, Создать -> консольное приложение win32 -> далее -> снять галку с предкомпилированного заголовка и поставить на пустой проект — таким образом создавал или сразу пустой проект выбирал?
0 |
|
57 / 57 / 3 Регистрация: 23.03.2011 Сообщений: 567 Записей в блоге: 3 |
|
|
28.07.2013, 00:39 [ТС] |
11 |
|
Сразу создал пустой
0 |
|
Заблокирован |
|
|
28.07.2013, 00:51 |
12 |
|
Отключи в проекте Use Precompiled Headers. Это очевидно студия. Где-то был метод пофиксить это правильно, но я его не помню.
0 |
|
5493 / 4888 / 831 Регистрация: 04.06.2011 Сообщений: 13,587 |
|
|
28.07.2013, 00:52 |
13 |
|
Ещё раз:
Так создавали: Создать проект — Общие — Пустой ?
0 |
|
Заблокирован |
|
|
28.07.2013, 00:53 |
14 |
|
alsav22, если это то, что я подразумеваю, так будет и с пустым.
0 |
|
5493 / 4888 / 831 Регистрация: 04.06.2011 Сообщений: 13,587 |
|
|
28.07.2013, 01:02 |
15 |
|
alsav22, если это то, что я подразумеваю, так будет и с пустым. У меня, в пустом, по умолчанию не использовать. Вроде бы, нигде не настраивал.
0 |
|
Заблокирован |
|
|
28.07.2013, 01:05 |
16 |
|
Галки «не использовать» нету. Определись уже. И заодно сразу дальше рассказывай какой версией собираешь, что студия и так очевидно.
0 |
|
alsav22 |
|
28.07.2013, 01:19
|
|
Не по теме:
Определись уже. Мне определиться? И в чём?
0 |
|
Даниил 68 / 41 / 1 Регистрация: 14.05.2013 Сообщений: 383 |
||||
|
28.07.2013, 11:59 |
18 |
|||
|
Кстать правильно пишется stdafx
У меня в 2008 работает такое
0 |
|
Don’t worry, be happy 17781 / 10545 / 2036 Регистрация: 27.09.2012 Сообщений: 26,516 Записей в блоге: 1 |
|
|
28.07.2013, 12:04 |
19 |
|
0 |
|
57 / 57 / 3 Регистрация: 23.03.2011 Сообщений: 567 Записей в блоге: 3 |
|
|
28.07.2013, 13:35 [ТС] |
20 |
|
именно так и делаю я
0 |



