Sign in to follow this  
grechzoo

SDL Globals.h doesn't seem to be working right

Recommended Posts

grechzoo    100
[size="4"]using globals.h im hoping to store a vector of rectangles and also a collision box and a few global bools[/size]

[size="4"]globals.h[/size]

[color="#000000"]
[code]
extern SDL_Rect winRect;

extern std::vector<SDL_Rect> platform;

extern bool paused;
extern bool exit;[/code]


[size=2]i then set the bool to false as so in the globals.cpp.[/size][/color]
[size="4"][size=3]
[code]
bool paused = false;
bool exit = false;[/code]
[/size][/size]

[size="4"]however then when i try and use the global winRect SDL_Rect or the global vector of SDL_Rects in other classes the compiler spits out the "undefined reference to platform" or "to winRect". which i cant understand because they are set up in the globals.h file, and the globals.h is included within the class header that is trying to use them[/size]

[size="4"]do i need to define anything else regarding the vector and Rect in the globals.cpp file?[/size]

[size="4"]might there be something wrong with the order of my header inclusions for the class im trying to manipulate the globals with?[/size]

[size="4"]hope there is an easy solution to this, im sure im just missing something.[/size]

Share this post


Link to post
Share on other sites
Wooh    1088
You need to put winRect and platform in one of you source files like you do with paused and exit.
[code]SDL_Rect winRect;
std::vector<SDL_Rect> platform;[/code]

Share this post


Link to post
Share on other sites
grechzoo    100
i did try that before but it didn't work, tried it again now and now things are great.

maybe i needed to save all my files before it would work.

thanks a lot!!!! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this