Jump to content
  • Advertisement

Archived

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

Possibility

how to use global enum w/ multiple files?

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

I have been using enums in my game, but I cant figure out how to make them accessible with multiple files. If I define the enum in main.cpp file, and then put it in the main.h file which all the other source files access, it says its being redefined. when I have say a global int, I declare it in the main.cpp and in the main.h like in main.cpp int variable = 10; amd then in main.h extern in variable; but how do i do the basic same thing with an enum? thanks for any help Possibility

Share this post


Link to post
Share on other sites
Advertisement
just include the enum in a header file and then #include the header

note that the headers you write yourself should be #included with quotes

ie

#include "myheader.h"

and not brackets


adamm@san.rr.com

Share this post


Link to post
Share on other sites
oh yeah...
you need to use include guards to prevent it from being redefined

so say this is a sample header.. called myheader.h

you''d do something like this


#ifndef _MYHEADER_H
#define _MYHEADER_H

// the stuff for the include file

#endif

you want to do this with EVERY header file you write


adamm@san.rr.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!