#### Archived

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

## Recommended Posts

Ok, I''ve seen some topics on this but I still don''t understand it completely. When I make a header file I do it like this:

// .H file

// Includes

// Other stuff




// .CPP file

// Functions


Now I want to include this in my project. I including the .h file in my game.cpp file enough or do I need to add the header and cpp file to my project(MSVC6)? And how do I turn my newly created header file into precompiled format and wich files do I need to distribute to my friends if they want em? thx and sorry for the question that has been asked 1000 times before. Sand Hawk ---------------- -Earth is 98% full. Please delete anybody you can.
My Site

##### Share on other sites
This code:
// Includes
// Other stuff
is not exactly essential for a header file. What it does is ensures that your compiler
only includes the file once . the #ifndef is like an if statement that checks to see if
was defined. If you only included your file once then MY_HEADER was not defined , so you
define it (#define MY_HEADER). Now if you accidently included your file twice like so:

when the compiler processes the #ifndef MY_HEADER line in my_header for the second time
confusing , but this is pretty much how it works (i think , i might be wrong). But if you dont
under stand how it works just know that it prevents your header from being included into

*Inhales*

Now , im VC++ when you create a header it should be automatically be added to your project.
I think there is a little edit box that you specify what project to add it to. As for headers that werent
created within a project i think they do have to be added to the project , but even if they dont need
to be added to a project its still a good idea to do so.

Hope this helps you

##### Share on other sites
This code:
// Includes
// Other stuff
is not exactly essential for a header file. What it does is ensures that your compiler
only includes the file once . the #ifndef is like an if statement that checks to see if
was defined. If you only included your file once then MY_HEADER was not defined , so you
define it (#define MY_HEADER). Now if you accidently included your file twice like so:

when the compiler processes the #ifndef MY_HEADER line in my_header for the second time
confusing , but this is pretty much how it works (i think , i might be wrong). But if you dont
under stand how it works just know that it prevents your header from being included into

*Inhales*

Now , im VC++ when you create a header it should be automatically be added to your project.
I think there is a little edit box that you specify what project to add it to. As for headers that werent
created within a project i think they do have to be added to the project , but even if they dont need
to be added to a project its still a good idea to do so. As for what files you need to distribute , Unless
you are drawing data from external files (via fopen() or other functions like that) you should only need
to distribute the resulting exe file. All source , header and resource files get compiled into your exe file.

Hope this helps you

##### Share on other sites
This code:
// Includes
// Other stuff
is not exactly essential for a header file. What it does is ensures that your compiler
only includes the file once . the #ifndef is like an if statement that checks to see if
was defined. If you only included your file once then MY_HEADER was not defined , so you
define it (#define MY_HEADER). Now if you accidently included your file twice like so:

when the compiler processes the #ifndef MY_HEADER line in my_header for the second time
confusing , but this is pretty much how it works (i think , i might be wrong). But if you dont
under stand how it works just know that it prevents your header from being included into

*Inhales*

Now , im VC++ when you create a header it should be automatically be added to your project.
I think there is a little edit box that you specify what project to add it to. As for headers that werent
created within a project i think they do have to be added to the project , but even if they dont need
to be added to a project its still a good idea to do so. As for what files you need to distribute , Unless
you are drawing data from external files (via fopen() or other functions like that) you should only need
to distribute the resulting exe file. All source , header and resource files get compiled into your exe file.

Hope this helps you

##### Share on other sites
This code:
// Includes
// Other stuff
is not exactly essential for a header file. What it does is ensures that your compiler
only includes the file once . the #ifndef is like an if statement that checks to see if
was defined. If you only included your file once then MY_HEADER was not defined , so you
define it (#define MY_HEADER). Now if you accidently included your file twice like so:

when the compiler processes the #ifndef MY_HEADER line in my_header for the second time
confusing , but this is pretty much how it works (i think , i might be wrong). But if you dont
under stand how it works just know that it prevents your header from being included into

*Inhales*

Now , im VC++ when you create a header it should be automatically be added to your project.
I think there is a little edit box that you specify what project to add it to. As for headers that werent
created within a project i think they do have to be added to the project , but even if they dont need
to be added to a project its still a good idea to do so. As for what files you need to distribute , Unless
you are drawing data from external files (via fopen() or other functions like that) you should only need
to distribute the resulting exe file. All source , header and resource files get compiled into your exe file.

Hope this helps you

##### Share on other sites
It doesn''t really helps alot, but thx for the time. Also, you didnt needed to post it 4 times . The stuff about the inclusion guards aren''t new to me. Just the Q about how to precompile em and if I need to specificly add them to the project or isn''t that necesarry?

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.

My Site

##### Share on other sites
Sand_Hawk:

Yeah, you have to add them to the project. Once you''ve done that, VC++ won''t recompile them unless you''ve made changes to the code. If you want to send it to your friends (with VC++ I presume), just send all of the .cpp and .h files, along with the workspace and other VC++ created files in a .zip file.

John.

##### Share on other sites

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.

My Site

• ### Forum Statistics

• Total Topics
628382
• Total Posts
2982366

• 10
• 9
• 15
• 24
• 11