Solved

"Unexpected end of file" ?

Posted on 2000-05-08
7
453 Views
Last Modified: 2010-04-02
 On several of my Visual C++ 6 projects, I get an "Unexpected end of file" error when I attempt to compile my program.  I can't seem to figure out what this means, and it happens in several different programs- any idea what this is?
-Delion
0
Comment
Question by:Delion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 75 total points
ID: 2789604
You'll have to add a

#include "stdafx.h"

at the beginning of your source files (and also make sure that there is such a file in the same directory, even if it's empty). VC++ uses this to create its precompiled headers. Either you'll have to turn off using precompiled headers (not recommended IMHO) in the project settings, or you'll have to live with this inconvenience....
0
 
LVL 1

Expert Comment

by:BSoeters
ID: 2790227
I slightly disagree with jkr...

It could well be that you include (the same) header file in all those projects.

If there's a syntax error somewhere in that header file, perhaps a missing semi-colon or something like that, or a missing closing brace, anything, it could be responsible for your "unexpected end of file".
0
 

Author Comment

by:Delion
ID: 2793656
Adjusted points from 50 to 75
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Delion
ID: 2793657
 Ok- I added "stdafx.h" to all of my source files and that fixed all of the problems except one.  Here's the remaining one:
  I copied the source files from a DirectX SDK sample program, DDrawEx4, to a new project to see if I could figure out what each part of the sample program does by fiddling with it.  Essentially, I inserted the .cpp and .h files and bitmap into a new workspace.  
  Both the main source file (formerly called ddex4.cpp) and another source file in the project gave the "unexpected end of file" error, and "StdAfx.h" fixed the bug with ddex4.cpp.  However, if I add StdAfx.h to the other one it gives me new errors while linking during the compile instead:
"
Conquest.obj : error LNK2001: unresolved external symbol _DirectDrawCreateEx@16
and
"Conquest.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7"
Any idea what's causing this with this file?
-Delion
P.S.  Do you know how the DirectX sample program gets away without using "StdAfx.h"?
0
 
LVL 1

Expert Comment

by:BSoeters
ID: 2793896
Are you sure you're linking to ddraw.lib (or some similar file) ?
0
 
LVL 86

Expert Comment

by:jkr
ID: 2793913
>>Do you know how the DirectX sample
>>program gets away without
>>using "StdAfx.h"?

See 'Project->Settings->C++->Precompiled Headers'. There you can set through wich header the precompiled headers are handled. VC++ sets the default to 'stdafx.h' for generated projects.


>>unresolved external symbol
>>_DirectDrawCreateEx@16

Did you include ddraw.lib to your project?
0
 

Author Comment

by:Delion
ID: 2797356
 I have ddraw.lib in my vc98 include lib folder, if that's what you mean.  In either case, I'm going to start over and try working with directX by starting a new program from scratch instead of editing the existing sample, so I'll try that and post a new question if I have any troubles.  Thanks for the help with the stdafx.h thing- that fixed the rest of my problems.
-Delion
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question