• Advertisement
Sign in to follow this  

help with #include

This topic is 4775 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 working on this program for a while now, and i suddenly decided to make my life much easier and separate the project into separate files. after separate each file into separat .h headers i keep on getting strange messages. does anyone have a tutorial on preprocessors out there? thanks

Share this post


Link to post
Share on other sites
Advertisement
yes, well some.
i use ifndef....and thats about it
the biggest one is that it keeps on saying that a global variable and function is being declared more than once

Share this post


Link to post
Share on other sites
Yeah, use the extern keyword to define global variables (then declare it in a source file)... eg:

Header.h:
extern int SomeInt;

Code.cpp:
int SomeInt;

And make sure you ALWAYS do the following:

Header.h:
#ifndef HEADER_H
#define HEADER_H

//stuff

#endif

Share this post


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

  • Advertisement