Archived

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

iNsAn1tY

Slight problem with OpenGL in MFC...

Recommended Posts

I'm new to MFC, and don't have too much experience with C++ in general. However, I'm an experienced C programmer, and in my C/Win32 programs, I declare structs, extern variables, macros, enums, basically stuff used by the whole program, in a header file called "shared.h". I attempted to do this in an MFC program, but got into something of a tangle. My problem is this: I declared a vec3_t struct, and put it into a file called "shared.h". Then, I created two classes: a camera class called CCamera, and a window class called C2DWnd, which is derived from CWnd. CCamera uses vec3_t, so it needs to have "shared.h" included. C2DWnd has a camera, so it needs "Camera.h". When I include "C2DWnd.h" in other files, I have to check all my #includes. To cut a long story short, all my #includes are now messed up, and I'm getting the usual hundred or so errors Visual C++ spews up when it can't find classes and structs. I'm wondering where I should put global declarations for structs, extern variables, macros, enums, etc. in a C++/MFC program. Can anyone provide an answer?

Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]

Share this post


Link to post
Share on other sites
Why shared.cpp of course. Actually, I''m not joking.

shared.h:
#ifndef __SHARED__
#define __SHARED__
extern Class instance;
#endif

shared.cpp
#include "shared.h"
Class instance;


And then ''instance'' can be accessed from any file that includes shared.h. Of course ''Class'' would have to be defined within shared.cpp''s scope.

Share this post


Link to post
Share on other sites
Thanks haro. The shared.h file is never repeatedly defined (the #ifndef pre-processor stuff), and anything which needs to be declared globally goes in a file called shared.cpp. Happy, happy, happy



Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You''re Already Here | The Best Film Reviews ]

Share this post


Link to post
Share on other sites