Solved

"Unexpected end of file" ?

Posted on 2000-05-08
7
443 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

863 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

22 Experts available now in Live!

Get 1:1 Help Now