Jump to content
  • Advertisement


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


#ifndef _MAIN_H? #define _MAIN_H? #endif ?

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

What are these #ifndef _MAIN_H? #define _MAIN_H? #endif ? doing and how do i use them properly. I see them popping up alot

Share this post

Link to post
Share on other sites
They're inclusion guards, to prevent things from being declared more than once if they appear in a file.

For example, if you put:
#include "Log.h"

Inside of SomeClass.h, then include SomeClass.h in a .cpp file where Log.h is already defined, you don't get a bunch of errors spit back at you.

Okay, that sounds stupid =P

- class CLog;
- #include "Log.h"
- class SomeClass;
- #include "Log.h"
- #include "SomeClass.h"

No errors about how CLog is already declared.

[edited by - GroZZleR on February 29, 2004 2:20:08 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!