Solved

"Unexpected end of file" ?

Posted on 2000-05-08
7
441 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
  • 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now