Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Error in Visual C++ (http://www.chiefdelphi.com/forums/showthread.php?t=28414)

Ashley Weed 05-05-2004 09:29

Error in Visual C++
 
My software came in yesterday, and I was so excited to finally have something to do during my 3 week break from classes. I successfuly installed Visual Studio .NET 2002, and started with a program from a CMPSC class I will be taking next fall. I typed in my first program, and attempted to run it and received this error:
fatal error C1010: unexpected end of file while looking for precompiled header directive

The program I was running can be found here under programming assignments:
Lab Excercise

Could it be as simple as I need more updates in my 2002 version for the program? .... is there an idiots guide to Visual Studio? ;)

Thanks!

[edit] additional information: when program first starts to run an error box pops up with the following - These project configuration(s) are out of date: C++ Projects - Debug Win32 Would you like to build them? [/edit]

Jay Lundy 05-05-2004 09:42

Re: Error in Visual C++
 
I don't know why Visual C++ uses precompiled headers by default, but you should probably just disable it.

Goto Project -> "Enter project name here" properties (should be the last option). Under the C/C++ folder goto "Precompiled Headers". Under "Create/Use Precomiled Header" select "Not Using Precompiled Headers".

Ashley Weed 05-05-2004 11:47

Re: Error in Visual C++
 
Quote:

Originally Posted by Jay Lundy
I don't know why Visual C++ uses precompiled headers by default, but you should probably just disable it.

Goto Project -> "Enter project name here" properties (should be the last option). Under the C/C++ folder goto "Precompiled Headers". Under "Create/Use Precomiled Header" select "Not Using Precompiled Headers".


Thanks for the suggestion, but I'm so confused at this point that I can't even locate "properties". I found a drop box on the right hand side, but there is nothing within it. I think I need to find a good beginners book that goes back and explains the simplest terms to me (GUI, ATL, OOP, etc? what's this!).

Since I am working in Visual Studio .NET, should I find a Visual C++ book, or would I be just as well of with a good C++ text? (Sorry, I don't know if there is a difference between C, C#, C++, or VC.)

Greg Perkins 05-05-2004 11:50

Re: Error in Visual C++
 
Ashley, your about as knowledgeable w/ c++ as i am, wish i could help you out.

Ryan M. 05-05-2004 13:08

Re: Error in Visual C++
 
Quote:

Originally Posted by Ashley Weed
Since I am working in Visual Studio .NET, should I find a Visual C++ book, or would I be just as well of with a good C++ text? (Sorry, I don't know if there is a difference between C, C#, C++, or VC.)

Teach Yourself Visual C++ in 21 days is a good book for Visual C++. (Don't remember how updated it is/what the most recent version is.)

I'de get a Visual C++ specific one, as VC++ is "special" in many ways... :)

Max Lobovsky 05-05-2004 18:59

Re: Error in Visual C++
 
Quote:

Originally Posted by Texan
I'de get a Visual C++ specific one........

Was that a humurously ironic typo or a joke (I'de=IDE)?

phrontist 05-05-2004 20:00

Re: Error in Visual C++
 
Oh how I loathe VC++

I remember trying to compile a program, which was perfect ANSI C, and becoming quite frustrated. So I googled, and to my shock and horror read the following:


Quote:

VC++ doesn't comply to ANSI C
My face looked a lot like this: :eek:

It's not a real compiler, it doesn't adhere to the definition of what a real compiler is supposed to do!

Typical M$ attitude: "Oh we 0wnz0rs teh ma55es! We don't n33d not stinkin' standards!!!1!" (Yes, Microsoft engineers actually speak l33t) ;)

*sob*

Ashley Weed 05-05-2004 20:26

Re: Error in Visual C++
 
So I am guessing each one of these really are different in their own way? C varies from C++, and VC++, and C#? What is C#?

I believe I will have to concentrate purely on VC++ at the moment. However, with my new major (IST), I am sure I will be learning more along the way. Is there an easier way to learn VC++ by learning another first? I attached the course outline below as informative or maybe humor for some of you.

Course Outline: Computer Science 101 is primarily a course in problem solving and computer programming. Topics include the following: the Visual C++ development environment; data types; operators; Input/Output (I/O); control structures including the if, for, while, and do-while statements; arrays, pointers, and reference variables; searching and sorting of arrays; functions and parameters; local variables; introduction to classes; text file I/O. Visual C++ is the vehicle language.

Guest 05-05-2004 20:34

Re: Error in Visual C++
 
Wierd how it says "Visual C++ is the vehicle language." C++ is a language, VC++ is not.

Max Lobovsky 05-05-2004 21:06

Re: Error in Visual C++
 
C++ is the name of the language you are learning (not to be confused with C, which is mostly C++ minus the OOP (Object Oriented Programming)). VC++ is Microsoft's IDE (integrated development environment) which, for the most part, complies with ANSI C++. The V (visual) just comes from the fact that the IDE has a bunch of features for making GUI (graphical user interfaces) pretty easily. C# is Microsoft's main competition towards Java. It is C++ with even more OOP stuff and made into a semi-compiled, semi-interpreted language, like Java.

Greg Ross 05-05-2004 21:38

Re: Error in Visual C++
 
Quote:

Originally Posted by Ashley Weed
I typed in my first program, and attempted to run it and received this error:
fatal error C1010: unexpected end of file while looking for precompiled header directive

The program I was running can be found here under programming assignments:
Lab Excercise

...

[edit] additional information: when program first starts to run an error box pops up with the following - These project configuration(s) are out of date: C++ Projects - Debug Win32 Would you like to build them? [/edit]

I ran the Lab Excercise without any problem. I poked around in VS.NET's help, and finally figured out that your precompiled header option is probably set in the "CL" environment variable. Look for /Yu or /Yufilename. Delete any of those you find, if you don't want to use precompiled headers.

As to the message "These project configuration(s) are out of date: C++ Projects - Debug Win32 Would you like to build them?", that's normal whenever you try to "Run" a project without compiling it first.

Astronouth7303 06-05-2004 07:27

Re: Error in Visual C++
 
I would also recomend "Sam's Teach yourself Visual C++ in 21 days". The version we have is for 6.0, but there probably is a .NET version, too.

I think 'Visual' comes from the OOP, but I'm not positive. (C++ is mostly code, anyway)

[And C# is a scripting version of C++. I'm sceptical about it.]

rbayer 06-05-2004 12:46

Re: Error in Visual C++
 
Alright, here's a quick run-down of PCH (pre-compiled headers):

In REALLY big projects, there are sometimes files that need to be included in every other file (like externs for global variables, a few function prototypes, maybe even a few classes).

Normally, #include works like copy-paste in C++ files (ie, the #included file is literally inserted in place of the #include). This is done by the preprocessor, so the compiler doesn't even know that there used to be a #include.

In large projects, this means that the #included file will have to be re-compiled as part of each file in which it was included. This can be a HUGE time-waster since it will compile to the same thing every single time.

With PCHs, the development environment essentially keeps track of these files specially, compiles them once, and then essentially copy-pastes the compiled code into each file instead of the raw source. Thus, the compiler only needs to compile it once, and much time could be saved.



Now, on to your problem:
1. PCHs are almost useless in small projects. Avoid them unless you actually need them.

2. VC++ disagrees with me. Whenever it creates a new project, it automatically assumes you want PCHs.

3. VC++ doesn't like being told it's wrong. If it can't find the #include of the PCH, it will complain.

There are two solutions to the problem:

1. Turn off precompiled headers in your project. I don't have a copy of .NET, but in VC++ 6.0, you do this by going to Project -> Settings -> C/C++ tab, choose "Precompiled Headers" from the category drop-down box, and select "Not using precompiled headers".

2. Give in to VC++ and simply add a #include "stdafx.h" to the top of every file. (stdafx.h is the name VC++ gives to the PCH).


While we're on the topic, if you're just learning C++, you should always tell VC++ to create a "Win32 console application" and make it of the "Hello, World!" type. Then, just delete the main function they give you and replace it with your own.

Greg Ross 06-05-2004 13:17

Re: Error in Visual C++
 
Quote:

Originally Posted by rbayer
1. Turn off precompiled headers in your project.... do this by going to Project -> Settings -> C/C++ tab, choose "Precompiled Headers" from the category drop-down box, and select "Not using precompiled headers".

In my version of Visual Studio .NET, there is no "Project -> Settings". That's why I had to come up with the environment variable solution.

BTW, I just tried adding CL=/Yu to my environment variables, and got the same error that Ashley did. I also tried adding #include "stdafx.h" like Rob suggested, and that didn't get rid of the error. So I still stand by my fix... at least until Ashley tells me there is no CL=/Yu in her environment. :)

Ryan M. 06-05-2004 14:51

Re: Error in Visual C++
 
Quote:

Originally Posted by maxlobovsky
VC++ is Microsoft's IDE (integrated development environment) which, for the most part, complies with ANSI C++.

Actually, it doesn't comply on a lot of things, only things like "Yeah, we use brackets to indicate the end of a class." ;)

Quote:

Originally Posted by maxlobovsky
The V (visual) just comes from the fact that the IDE has a bunch of features for making GUI (graphical user interfaces) pretty easily.

Plus it has a lot of completely non-standard like functions for graphics. (which saying something, since there is no standard...) :)


All times are GMT -5. The time now is 07:12.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi