Struct Problem...

Started by
11 comments, last by Cyberdrek 23 years, 9 months ago
Here is the sample code that I''m actually working on. typedef struct tDX { LPDIRECTDRAW pDD; // A DirectDraw object LPDIRECT3DRM pD3DRM; // A Direct3D RM object LPDIRECTDRAWSURFACE pDDSPrimary; // DirectDraw primary surface LPDIRECTDRAWSURFACE pDDSBack; // DirectDraw back surface LPDIRECTDRAWPALETTE pDDPal; // Palette for primary surface LPDIRECTDRAWCLIPPER pClipper; // Clipper for windowed mode LPDIRECT3DRMDEVICE pD3DRMDevice; // A device LPDIRECT3DRMVIEWPORT pViewport; // A viewport LPDIRECT3DRMFRAME pCamera; // A camera LPDIRECT3DRMFRAME pScene; // The scene LPDIRECT3DRMFRAME pCube; // The one and only object in our scene BOOL bFullScreen; // Are we in full-screen mode? BOOL bAnimating; // Has our animating begun? HWND ddWnd; // HWND of the DDraw window } tDX; Ok, when I try to compile my project, it gives the error( I get 20 of them ): d:\program files\microsoft visual studio\myprojects\theknightslair\gamemain.h(27) : error C2146: syntax error : missing '';'' before identifier ''pD3DRM'' d:\program files\microsoft visual studio\myprojects\theknightslair\gamemain.h(27) : error C2501: ''LPDIRECT3DRM'' : missing storage-class or type specifiers d:\program files\microsoft visual studio\myprojects\theknightslair\gamemain.h(27) : error C2501: ''pD3DRM'' : missing storage-class or type specifiers Now, I include ddraw.h, d3d.h and I have all the DX libs added in the setup of my project. Can anyone tell me where''s the beef. I really don''t understand why a simple struct gives me an error... Cyberdrek Headhunter Soft DLC Multimedia Two Guys Soft
[Cyberdrek | ]
Advertisement
Are the DX includes _before_ the definition of the struct?

- Muzzafarath

Mad House Software
The Field Marshals
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Is it legal to define and instantiate the struct with the same name, eg; "tDX"?
I don''t think it! Try this instead:

typedef struct {
LPDIRECTDRAW pDD; // A DirectDraw object
LPDIRECT3DRM pD3DRM; // A Direct3D RM object
LPDIRECTDRAWSURFACE pDDSPrimary; // DirectDraw primary surface
LPDIRECTDRAWSURFACE pDDSBack; // DirectDraw back surface
LPDIRECTDRAWPALETTE pDDPal; // Palette for primary surface
LPDIRECTDRAWCLIPPER pClipper; // Clipper for windowed mode
LPDIRECT3DRMDEVICE pD3DRMDevice; // A device
LPDIRECT3DRMVIEWPORT pViewport; // A viewport
LPDIRECT3DRMFRAME pCamera; // A camera
LPDIRECT3DRMFRAME pScene; // The scene
LPDIRECT3DRMFRAME pCube; // The one and only object in our scene
BOOL bFullScreen; // Are we in full-screen mode?
BOOL bAnimating; // Has our animating begun?
HWND ddWnd; // HWND of the DDraw window
} tDX;

- Muzzafarath

Mad House Software
The Field Marshals
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
or do:
typedef struct sDX
{
} tDX;
Ok, first of all the includes are always before my struct. Second of all, instantiating a struct with the same name as the struct, works. I''ve always done it especially in when I was coding for Two Guys Soft and second of all, I''ve already tried with just:

typedef struct {
} blah;

that also doesn''t work. The error is not the struct definition but rather the delacration of the Direct X variables needed in my wrapper. Check the bottom of the message for the error messages before replying...



Cyberdrek
Headhunter Soft
DLC Multimedia
[Cyberdrek | ]
That syntax error (first message) could be causing an avalanche of other messages, and I''d focus on fixing it first. That''s why I suspected the dual name issue. Try commenting out the struct and see if previous code is in error. BTW, just trying to help...
Trust me... it''s _most_ probably a header problem. Are you including d3drm.h before the struct? If the struct is in your header, make sure to include the d3drm.h in your _cpp_ file too.

OldManDave.
All: Thanks for the help.
OldManDave: I wasn''t including that file. Thanks for the info...



Cyberdrek
Headhunter Soft
DLC Multimedia
[Cyberdrek | ]
Why are everybody using typedef? Why not just create the damn struct and declare it either static or extern?

Zeblar Nagrim, Lord of Chaos

This topic is closed to new replies.

Advertisement