Archived

This topic is now archived and is closed to further replies.

Struct Problem...

This topic is 6360 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

Zeblar Nagrim


Why are everybody using typedef? Why not just create the damn struct and declare it either static or extern?


The reason why people use typedef before the struct is simply ( for me at least ) because it''s a habit from Borland C++ 4.0 for DOS. If you didn''t typedef''d the damn struct, you couldn''t just define the instance by typing: blah_struct blah. You had to use
struct blah_struct blah. This is the reason why I always typedef my struct.



Cyberdrek
Headhunter Soft
DLC Multimedia

Share this post


Link to post
Share on other sites
try "Rebuild All" in the Build menu... if that doesnt work then you havent included all the headers to your source code, or you''re not linking to the libs needed to compile Direct3D code..


..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites