• Advertisement
Sign in to follow this  

Sharing display dimensions between source files - C++/Allegro

This topic is 1959 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

Ok, so I'm trying to make a simple game, and instead of hardcoding my starting values for the player's image location, I want to calculate the position based on display size. My problem is that in my player's implementation file, the Allegro display is not defined. I also can't find a way to get a const to span object files (since I'm compiling each .h/.cpp combination into a .o and then combining the .o files). And the #define directive does not span object files either. Am I going about it the wrong way, or am I going to have to just define the SCREEN_W and SCREEN_H variables in each header? Edited by swiftcoder

Share this post


Link to post
Share on other sites
Advertisement
We prefer that you post the solution to your problem, rather than deleting your post.

It seems to me that you should declare the const variables in one header file, implemented them in the matching .cpp file, and import the headed in each other header file.

Share this post


Link to post
Share on other sites
I didn't realize that I needed to extern the variables in all the files, but define them only in the main source. Thanks for the suggestion.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement