Skip to main content
gamedev.net
🔒 Locked

C++ syntax error.

Started by cyberben 6 replies 1.3k views
Original Post
cyberben
cyberben
Hi there, I''m having a very strange problem. The top of my code file looks like this:
    
#include <windows.h>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <ddraw.h>
#include <dinput.h>
#include <d3d.h>
#include <d3dtypes.h>
//#include <dsound.h>
#include "Prototypes.h"


#define D3D_OVERLOADS

LPDIRECT3D7			lpD3D = NULL;
LPDIRECT3DDEVICE7	lpDevice = NULL;

    
And as you can see I''m re-writing my game engine from assembler to C++ because I couldn''t get Network and D3D running properly in assembler without hundreds of hours of effort (Just to get it running let alone building the engine!) So anyhow I get the following error: e:\epsilon\d3d.cpp(16) : error C2146: syntax error : missing '';'' before identifier ''lpD3D'' e:\epsilon\d3d.cpp(16) : error C2501: ''LPDIRECT3D7'' : missing storage-class or type specifiers e:\epsilon\d3d.cpp(16) : fatal error C1004: unexpected end of file found Where line 16 is the obvious declaration for lpD3D. I also get this same error with my DDraw init stuff.... I never did before, and I''ve already had this running, what''s wrong? FYI I''m building an isometric engine w/ DDraw and D3D for acceleration... If your wondering why I have both sets of includes... Thanks, Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
Snale
Snale
Perhaps you have forgot to include a header file.
Another potential problem might be your own header file, prototypes.h.
If you have declared a class in it like this:

class something
{
... code ...
};

you must not forget the ending ";". Since header files are included a syntax error will be carried along to all files it is included in.



Snale
+--Java Game
PGmeiner
PGmeiner
Hi,

i know this type of error. You will get this error when a class is not defined. In your case the class LPDIRECT3D7 is not defined (as you can see in the second error). I think you forgot to include one or more Header-Files. So check in which Header-File the class LPDIRECT3D7 is defined and include it.

good luck

Peter G.

Peter Gmeiner
codemonkey
codemonkey
Yes, normally that is a nice abscure way of saying "I don''t know what datatype your talking about."

If you did something like:

struct MyStruct
{
int i;
};

void main()
{
// Misspell the datatype on purpose...
MyStructure Temp;
Temp.i = 0;
}

Usually you''ll get an error stating that "Temp" is missing a semicolon with some "storage-class" error.

However you will receive a similar one if you do not have semicolons at the end of your class declarations as Snale has mentioned... and sometimes it can be within a nested set of #includes, and therefor hard to find. However that usually leads in code with 102 errors, or at least more then 3

Hope that assists.

CodeMonkey
CODE Monkey
cyberben
cyberben
Yah I saw most of this in the help files... except if you look at my source included there, I HAVE included both the D3D and D3DType header files and the DDRaw ones for DirectDraw... it doesn''t make anysense! They are defined in those header files which are included!?!?

There''s something fishy going on here!

Anymore more ideas?
Thanks,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
null_pointer
null_pointer
OK, just calm down!

That error occurs _after_ the line where the real syntax error is located, so look at what is immediately before line 16.Like everyone said:


class example {} // <-- actual problem!!

void function() // syntax error: missing '';'' before...
{
}



It can happen with enum, or just about anything that requires a '';''. You''ll have to post the code.

Good Luck!



- null_pointer
Sabre Multimedia
cyberben
cyberben
Ok, ok, I''ll admit it now. I was wrong you guys were right.
I just re-installed C++ and C++ comes with the DirectX 3 SDK.
So it couldn''t find the LPDIRECTDRAW7 and LPDIRECT3D7 objects cause it had vr. 3 of the includes!

I''m sorry.... the dumb mistakes I make sometimes! Well hey, I''ve learned something and will never again have this problem!

Thanks to all you who put up with me!
See ya,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.