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]
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.)
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:
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)
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.
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.
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.
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:
PCHs are almost useless in small projects. Avoid them unless you actually need them.
VC++ disagrees with me. Whenever it creates a new project, it automatically assumes you want PCHs.
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:
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”.
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.
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.
WINDOWS doesn’t like being told it’s wrong. MS wrote XP for the masses (read: assuming most are iliterate enough to not realize that they accidently deleted thier OS)
MFC supplies you with lots of basic stuff. I agree it’s like Word and HTMLs, but it’s better than doing it all yourself.
And all of the system calls and constants are already made (unlike VB). Check MSDN for specific headers for specific calls.