Solved

"Unexpected end of file" ?

Posted on 2000-05-08
7
450 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
Technology Partners: 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Writing a parser for java language 4 100
Why isn't object file created? 6 105
C++ Code Issue 4 47
c++  placing data into a form and an editbox 5 48
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…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

737 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