Page 1 of 1
Excellent Article Regarding Header/Source Files
Posted: Sat Nov 22, 2008 7:47 pm
by dandymcgee
If you're at all confused about the pros and cons of splitting your project into multiple source files, or if you have already decided to do so and are having some problems I would Highly recommend giving this article a read:
http://www.gamedev.net/reference/progra ... /orgfiles/
I'm so happy this exists, haha. It has helped me So much. Hopefully it will help someone else too.
Re: Excellent Article Regarding Header/Source Files
Posted: Sat Nov 22, 2008 7:54 pm
by avansc
the only important thing in that whole article was this
"Add an inclusion guard to every header file you make "
Code: Select all
#ifndef _INC_STDLIB
#define _INC_STDLIB
...
#endif _INC_STDLIB
i never knew people had such a hard time with something as elementary as header files.
Re: Excellent Article Regarding Header/Source Files
Posted: Sat Nov 22, 2008 10:24 pm
by JS Lemming
I've always had a hard time splitting things into header files. It seems abstract to me. How one thing could warrant having it's own file and another not. Who am I to decide such things. How could I?
Re: Excellent Article Regarding Header/Source Files
Posted: Sun Nov 23, 2008 11:16 am
by dandymcgee
Same here, I'm still trying to fully grasp the concept of exactly what sorts of things to put in which files. It's definitely simpler since I read that.
Re: Excellent Article Regarding Header/Source Files
Posted: Sun Nov 23, 2008 11:34 am
by Arce
Yeah, actually...The majority of my programming class looked at me like I was some kind of god because of the use of a few headers and source files...o.o;
Honestly, I never knew it was such a big deal either--there's no way in fuck I'd ever wade through all my source in a single file to find a function. Especially with larger programs...I'd simply kill myself.
The only thing I think would be difficult for others inexperienced with
neat code (headers and source files) would have a hard time with is cutting out problems with multiple declarations, and prototyping correctly...Both easy fixes.
I've always had a hard time splitting things into header files. It seems abstract to me. How one thing could warrant having it's own file and another not. Who am I to decide such things. How could I?
xD, congrats, you've managed to turn this discussion into some kind of a deep philosophical question. xD
I personally say follow your own rules, unless you're abiding by some kind of company standard...Just stay consistent, and you'll be good...
Re: Excellent Article Regarding Header/Source Files
Posted: Sun Nov 23, 2008 9:18 pm
by avansc
JS Lemming wrote:I've always had a hard time splitting things into header files. It seems abstract to me. How one thing could warrant having it's own file and another not. Who am I to decide such things. How could I?
its really not that hard.
if you are making a class, that automatically goes in its own class_name.h and class_name.c/cpp file
the declaration and prototypes go in the .h file and the definition goes in the source file.
if you are data type that gets its own header and source file.
headers always just have prototypes/declaration, and there is a corresponding .c/cpp files with the definitions/code of those member functions and jazz.
a main source file should always be very small. for a game maybe 100 lines.