|
|
|
start date: Wed, 15 Aug 2007 00:56:13 +0530,
posted on: microsoft.public.dotnet.languages.vc
back
| Thread Index |
|
1
Anil Gupte
|
|
2
Carl Daniel [VC++ MVP] am
|
|
3
Anil Gupte
|
|
4
Bo Persson
|
|
5
Ben Voigt [C++ MVP] am
|
|
6
pvdg42 am
|
|
7
Ben Voigt [C++ MVP] am
|
|
8
PvdG42
|
|
9
Anil Gupte
|
My Hello World failed!
I have never been so embarassed! :-) I have played with C++, and even
created a few simple programs, but decided to learn it properly. So I crack
a book, get into Visual Studio and follow the instructions to create the
following program:
// HelloWorld.cpp : Defines the entry point for the console application.
//
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
and I get an error:
c:\Projects\CPlus2\HelloWorld\HelloWorld.cpp(12): fatal error C1010:
unexpected end of file while looking for precompiled header directive
The code is exactly as shown in the book - (Visual C++ Step by Step by
Templeman and Olsen). What gives?
--
Anil Gupte
www.keeninc.net
www.icinema.com
Date:Wed, 15 Aug 2007 00:56:13 +0530
Author:
|
Re: My Hello World failed!
Anil Gupte wrote:
> I have never been so embarassed! :-) I have played with C++, and even
> created a few simple programs, but decided to learn it properly. So
> I crack a book, get into Visual Studio and follow the instructions to
> create the following program:
>
> // HelloWorld.cpp : Defines the entry point for the console
> application. //
> #include <iostream>
> using namespace std;
> int main()
> {
> cout << "Hello World!" << endl;
> return 0;
> }
>
> and I get an error:
>
> c:\Projects\CPlus2\HelloWorld\HelloWorld.cpp(12): fatal error C1010:
> unexpected end of file while looking for precompiled header directive
>
> The code is exactly as shown in the book - (Visual C++ Step by Step by
> Templeman and Olsen). What gives?
Add
#include "stdafx.h" as the first non-comment line in your .cpp file.
OR
Right-click on your .cpp file in the soluition explorer, choose
"Properties", and find the "Precompiled header files" option - change it to
"not using pre-compiled headers".
-cd
Date:Tue, 14 Aug 2007 12:32:34 -0700
Author:
|
Re: My Hello World failed!
Thanx for the response. Since I am learning VC++ (I am familiar with
VB.Net), I would appreciate it if you can tell me what that file was for and
why do you think the author forgot to mention it?
--
Anil Gupte
www.keeninc.net
www.icinema.com
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:u4oOenq3HHA.3900@TK2MSFTNGP02.phx.gbl...
> Anil Gupte wrote:
>> I have never been so embarassed! :-) I have played with C++, and even
>> created a few simple programs, but decided to learn it properly. So
>> I crack a book, get into Visual Studio and follow the instructions to
>> create the following program:
>>
>> // HelloWorld.cpp : Defines the entry point for the console
>> application. //
>> #include <iostream>
>> using namespace std;
>> int main()
>> {
>> cout << "Hello World!" << endl;
>> return 0;
>> }
>>
>> and I get an error:
>>
>> c:\Projects\CPlus2\HelloWorld\HelloWorld.cpp(12): fatal error C1010:
>> unexpected end of file while looking for precompiled header directive
>>
>> The code is exactly as shown in the book - (Visual C++ Step by Step by
>> Templeman and Olsen). What gives?
>
> Add
>
> #include "stdafx.h" as the first non-comment line in your .cpp file.
>
> OR
>
> Right-click on your .cpp file in the soluition explorer, choose
> "Properties", and find the "Precompiled header files" option - change it
> to "not using pre-compiled headers".
>
> -cd
>
>
Date:Wed, 15 Aug 2007 11:41:23 +0530
Author:
|
Re: My Hello World failed!
Anil Gupte wrote:
:: Thanx for the response. Since I am learning VC++ (I am familiar
:: with VB.Net), I would appreciate it if you can tell me what that
:: file was for and why do you think the author forgot to mention it?
I don't think the author forgot to mention this file. This is VC
specific.
When you create a new project, you get the Precompiled Header option
checked by default. The files generated by the project wizard will
also contains an #include "stdafx.h".
If you want to use your own code, uncheck the Precompiled Header and
check the Empty Project option instead. Then add any files you like.
Bo Persson
::
:: --
:: Anil Gupte
:: www.keeninc.net
:: www.icinema.com
::
:: "Carl Daniel [VC++ MVP]"
:: <cpdaniel_remove_this_and_nospam@mvps.org.nospam> wrote in message
:: news:u4oOenq3HHA.3900@TK2MSFTNGP02.phx.gbl...
::: Anil Gupte wrote:
:::: I have never been so embarassed! :-) I have played with C++,
:::: and even created a few simple programs, but decided to learn it
:::: properly. So I crack a book, get into Visual Studio and follow
:::: the instructions to create the following program:
::::
:::: // HelloWorld.cpp : Defines the entry point for the console
:::: application. //
:::: #include <iostream>
:::: using namespace std;
:::: int main()
:::: {
:::: cout << "Hello World!" << endl;
:::: return 0;
:::: }
::::
:::: and I get an error:
::::
:::: c:\Projects\CPlus2\HelloWorld\HelloWorld.cpp(12): fatal error
:::: C1010: unexpected end of file while looking for precompiled
:::: header directive
::::
:::: The code is exactly as shown in the book - (Visual C++ Step by
:::: Step by Templeman and Olsen). What gives?
:::
::: Add
:::
::: #include "stdafx.h" as the first non-comment line in your .cpp
::: file.
:::
::: OR
:::
::: Right-click on your .cpp file in the soluition explorer, choose
::: "Properties", and find the "Precompiled header files" option -
::: change it to "not using pre-compiled headers".
:::
::: -cd
Date:Wed, 15 Aug 2007 12:23:16 +0200
Author:
|
Re: My Hello World failed!
"Bo Persson" wrote in message
news:5ig2gdF3ous1sU1@mid.individual.net...
> Anil Gupte wrote:
> :: Thanx for the response. Since I am learning VC++ (I am familiar
> :: with VB.Net), I would appreciate it if you can tell me what that
> :: file was for and why do you think the author forgot to mention it?
>
> I don't think the author forgot to mention this file. This is VC specific.
The name of the book the OP was using started with "Visual C++", so that
would seem to be a rather serious oversight. Probably the new project
wizard has changed since the book was written, so it wasn't clear to the OP
that the "Empty Project" option needed to be checked.
>
> When you create a new project, you get the Precompiled Header option
> checked by default. The files generated by the project wizard will also
> contains an #include "stdafx.h".
>
> If you want to use your own code, uncheck the Precompiled Header and check
> the Empty Project option instead. Then add any files you like.
>
>
> Bo Persson
>
>
> ::
> :: --
> :: Anil Gupte
> :: www.keeninc.net
> :: www.icinema.com
> ::
> :: "Carl Daniel [VC++ MVP]"
> :: <cpdaniel_remove_this_and_nospam@mvps.org.nospam> wrote in message
> :: news:u4oOenq3HHA.3900@TK2MSFTNGP02.phx.gbl...
> ::: Anil Gupte wrote:
> :::: I have never been so embarassed! :-) I have played with C++,
> :::: and even created a few simple programs, but decided to learn it
> :::: properly. So I crack a book, get into Visual Studio and follow
> :::: the instructions to create the following program:
> ::::
> :::: // HelloWorld.cpp : Defines the entry point for the console
> :::: application. //
> :::: #include <iostream>
> :::: using namespace std;
> :::: int main()
> :::: {
> :::: cout << "Hello World!" << endl;
> :::: return 0;
> :::: }
> ::::
> :::: and I get an error:
> ::::
> :::: c:\Projects\CPlus2\HelloWorld\HelloWorld.cpp(12): fatal error
> :::: C1010: unexpected end of file while looking for precompiled
> :::: header directive
> ::::
> :::: The code is exactly as shown in the book - (Visual C++ Step by
> :::: Step by Templeman and Olsen). What gives?
> :::
> ::: Add
> :::
> ::: #include "stdafx.h" as the first non-comment line in your .cpp
> ::: file.
> :::
> ::: OR
> :::
> ::: Right-click on your .cpp file in the soluition explorer, choose
> ::: "Properties", and find the "Precompiled header files" option -
> ::: change it to "not using pre-compiled headers".
> :::
> ::: -cd
>
>
>
Date:Wed, 15 Aug 2007 08:08:41 -0500
Author:
|
Re: My Hello World failed!
"Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
news:eFaM01z3HHA.600@TK2MSFTNGP05.phx.gbl...
>
> The name of the book the OP was using started with "Visual C++", so that
> would seem to be a rather serious oversight. Probably the new project
> wizard has changed since the book was written, so it wasn't clear to the
> OP that the "Empty Project" option needed to be checked.
>
I'd like to see that book, as the oversight covers previous versions of
Visual Studio going back to VS 6. Our beginning C++ students are instructed
to *always* create empty Win32 console projects, then add a source code
file. We've used that procedure since VC 6 to avois the issue experienced by
the OP.
Possibly the OP missed the Empty Project step in the book?
Date:Wed, 15 Aug 2007 14:19:45 -0500
Author:
|
Re: My Hello World failed!
"pvdg42" <pvdg42@newsgroups.nospam> wrote in message
news:uk$LCF33HHA.3900@TK2MSFTNGP02.phx.gbl...
>
> "Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
> news:eFaM01z3HHA.600@TK2MSFTNGP05.phx.gbl...
>>
>> The name of the book the OP was using started with "Visual C++", so that
>> would seem to be a rather serious oversight. Probably the new project
>> wizard has changed since the book was written, so it wasn't clear to the
>> OP that the "Empty Project" option needed to be checked.
>>
> I'd like to see that book, as the oversight covers previous versions of
> Visual Studio going back to VS 6. Our beginning C++ students are
> instructed to *always* create empty Win32 console projects, then add a
> source code file. We've used that procedure since VC 6 to avois the issue
> experienced by the OP.
> Possibly the OP missed the Empty Project step in the book?
IIRC, no precompiled headers was the default in prior versions of VC, you
had to request skeleton code.
Date:Wed, 15 Aug 2007 14:25:05 -0500
Author:
|
Re: My Hello World failed!
"Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
news:efEiDI33HHA.1208@TK2MSFTNGP03.phx.gbl...
>
> "pvdg42" <pvdg42@newsgroups.nospam> wrote in message
> news:uk$LCF33HHA.3900@TK2MSFTNGP02.phx.gbl...
>>
>> "Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
>> news:eFaM01z3HHA.600@TK2MSFTNGP05.phx.gbl...
>
> IIRC, no precompiled headers was the default in prior versions of VC, you
> had to request skeleton code.
I have no installations of VS 2003 or earlier to help me remember, but we
instructed students to create empty projects in versions earlier than VS
2005 to avoid entanglements with some sort of code shell, I thought. Could
be my memory is bad, though :)
Date:Wed, 15 Aug 2007 16:42:20 -0500
Author:
|
Re: My Hello World failed!
Sorry, I have been away.
Yes, you are absolutely right - Mea Culpa. I overlooked the "Check the
Empty Project box" instruciton. It was at the top of the page and I just
glazed....
:-)
Thanx all!
--
Anil Gupte
www.keeninc.net
www.icinema.com
"pvdg42" <pvdg42@newsgroups.nospam> wrote in message
news:uk$LCF33HHA.3900@TK2MSFTNGP02.phx.gbl...
>
> "Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
> news:eFaM01z3HHA.600@TK2MSFTNGP05.phx.gbl...
>>
>> The name of the book the OP was using started with "Visual C++", so that
>> would seem to be a rather serious oversight. Probably the new project
>> wizard has changed since the book was written, so it wasn't clear to the
>> OP that the "Empty Project" option needed to be checked.
>>
> I'd like to see that book, as the oversight covers previous versions of
> Visual Studio going back to VS 6. Our beginning C++ students are
> instructed to *always* create empty Win32 console projects, then add a
> source code file. We've used that procedure since VC 6 to avois the issue
> experienced by the OP.
> Possibly the OP missed the Empty Project step in the book?
>
Date:Sun, 19 Aug 2007 09:39:57 +0530
Author:
|
|
|