Неустранимая ошибка c1010

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

10.1k3 gold badges36 silver badges81 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,6112 gold badges12 silver badges10 bronze badges

1

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

10.1k3 gold badges36 silver badges81 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,6112 gold badges12 silver badges10 bronze badges

1

HerMak

1 / 0 / 1

Регистрация: 26.12.2017

Сообщений: 35

1

05.03.2018, 16:45. Показов 9695. Ответов 5

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

Решил попробовать сделать змейку на чистом с++, но тут какая то ошибка, игру разрабатываю в Visual studio 2017 код ошибки С1010
непредвиденный конец файла во время поиска предкомпилированного заголовка. Возможно, вы забыли добавить директиву «#include «stdafx.h»»
Добавлял данную библиотеку-не помогло.

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
using namespace std;
const int width = 20;
const int height = 20;
int x, y;
int fruitx, fruity, score;
bool GameOver;
enum eDirection { STOP = 0, LEFT, RIHGT, UP, DOWN };
eDirection dir;
 
void SetUp()
{
    GameOver = false;
    dir = STOP;
    x = width / 2;
    y = height / 2;
    fruitx = rand() % width;
    fruity = rand() % height;
    score = 0;
}
void Draw()
{
    system("cls");
    for (int i = 0; i<width; i++)cout << "#";
    cout << endl;
 
    for (int i = 0; i<height; i++)
    {
        for (int j = 0; j<width; i++)
        {
            if (j == 0 || j == width - 1)
                cout << "#";
            cout << " ";
        }
        cout << endl;
    }
 
    for (int i = 0; i<width ; i++) cout << "#";
    cout << endl;
}
void Input()
{
 
}
void Logic()
{
 
}
int main(int argc, char** argv) {
    SetUp();
    while (!GameOver)
    {
        Draw();
        Input();
        Logic();
    }
    return 0;
}



0



3434 / 2813 / 1249

Регистрация: 29.01.2016

Сообщений: 9,426

05.03.2018, 16:46

2

Цитата
Сообщение от HerMak
Посмотреть сообщение

Добавлял данную библиотеку-не помогло.

Куда добавлял? Как добавлял? В коде ничего такого не наблюдаю. И это не библиотека.



0



1 / 0 / 1

Регистрация: 26.12.2017

Сообщений: 35

05.03.2018, 16:50

 [ТС]

3

Не библиотеку, извиняюсь, а вот такой строчкой
#include «stdafx.h



0



3434 / 2813 / 1249

Регистрация: 29.01.2016

Сообщений: 9,426

05.03.2018, 16:52

4

Цитата
Сообщение от HerMak
Посмотреть сообщение

а вот такой строчкой
#include «stdafx.h

Код со строчкой покажи.



0



HerMak

1 / 0 / 1

Регистрация: 26.12.2017

Сообщений: 35

05.03.2018, 16:52

 [ТС]

5

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include "stdafx.h"
using namespace std;
const int width = 20;
const int height = 20;
int x, y;
int fruitx, fruity, score;
bool GameOver;
enum eDirection { STOP = 0, LEFT, RIHGT, UP, DOWN };
eDirection dir;
 
void SetUp()
{
    GameOver = false;
    dir = STOP;
    x = width / 2;
    y = height / 2;
    fruitx = rand() % width;
    fruity = rand() % height;
    score = 0;
}
void Draw()
{
    system("cls");
    for (int i = 0; i<width; i++)cout << "#";
    cout << endl;
 
    for (int i = 0; i<height; i++)
    {
        for (int j = 0; j<width; i++)
        {
            if (j == 0 || j == width - 1)
                cout << "#";
            cout << " ";
        }
        cout << endl;
    }
 
    for (int i = 0; i<width ; i++) cout << "#";
    cout << endl;
}
void Input()
{
 
}
void Logic()
{
 
}
int main(int argc, char** argv) {
    SetUp();
    while (!GameOver)
    {
        Draw();
        Input();
        Logic();
    }
    return 0;
}



0



nd2

3434 / 2813 / 1249

Регистрация: 29.01.2016

Сообщений: 9,426

05.03.2018, 16:55

6

Лучший ответ Сообщение было отмечено HerMak как решение

Решение

Цитата
Сообщение от HerMak
Посмотреть сообщение

C++
1
#include "stdafx.h"

Это выше всех инклудов должно быть.



1



I’m getting the following error while compiling my project:

fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?

But if I add #include "StdAfx.h" as it required, more error will appear. What should I do please?

  • visual-studio
  • stdafx.h

Chris Catignani's user avatar

asked Nov 17, 2014 at 15:50

Ting Sun's user avatar

Ting SunTing Sun

1731 gold badge1 silver badge10 bronze badges

1 Answer

This is a Visual Studio issue with precompiled headers. If you compile a file and request precompiled headers you have to include this stdafx file. If you disable use of precompiled headers for either the project or for the file then you no longer have to include this header. Look though the project settings for the right checkbox or check the /Y options you are passing. /Y- can disable precompiled header usage.

answered Nov 17, 2014 at 16:33

patthoyts's user avatar

patthoytspatthoyts

32.4k3 gold badges62 silver badges93 bronze badges

Содержание

  1. Неустранимая ошибка C1010
  2. Комментарии
  3. Отключение предкомпилированных заголовков
  4. Fatal Error C1010
  5. Remarks
  6. To turn off precompiled headers
  7. Fatal error c1010 это
  8. Answered by:
  9. Question
  10. Answers
  11. All replies
  12. Name already in use
  13. cpp-docs / docs / error-messages / compiler-errors-1 / fatal-error-c1010.md
  14. Fatal error c1010 это
  15. Answered by:
  16. Question
  17. Answers
  18. All replies

непредвиденный конец файла при поиске предкомпилированного заголовка. Вы забыли добавить имя #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);
>

Источник

Понравилась статья? Поделить с друзьями:
  • Неустранимая ошибка c0000034 при операции обновления
  • Неустранимая ошибка appcache
  • Неумышленная ошибка подчас уводящая очень далеко от истины
  • Неустранимая аппаратная ошибка устройства ssd
  • Неустранимая аппаратная ошибка компонент amd northbridge