I think I understand what you all are trying to explain.
Because I'm writing my OS in asm, my philosophy is to put code in asm files that are included in the main file and then directly in binary compiled (however, this isn't really compilation at all. Maybe translation would be a better word).
That's why I don't have any problem putting functions in header files, but I agree that this is only possible because I'm not using separated compiling (which doesn't seems to have so much advantages to me.)
I apologize if I seemed to be locked in my meanings, but I guess that my OSdev choices are very different than these of most people here.
including header file
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:including header file
once your program will get larger, you'll have the compiler to read and compile everything everytime you change a line in one file ... in terms of compile time, you'll quickly see the advantage of separated compiling
Re:including header file
Time will decide for me.Pype.Clicker wrote: once your program will get larger, you'll have the compiler to read and compile everything everytime you change a line in one file ... in terms of compile time, you'll quickly see the advantage of separated compiling
But until it did, and as I'm using NASM and am "compiling" directly to binary, there's no compilation to be done, only translation, which is currently far faster than separated compiling of C code (for the same code).
Maybe in the future, when my code will become more important, the situation will be inverted, but for now, I think I will stay with my system
Re:including header file
I have no use for a linker and my loader is hand-made, so my entry in "a world of pain" has been delayed, it seems.Tim Robinson wrote: pini, we're being psycho-rigid for a reason!
... you will enter a world of pain, either from the linker or the loader.
It sounds like some of the people reading this board could do with revising their knowledge of the C programming language.
Don't misunderstand me : I'm still using C header file in the way most people do (as you described it), but I think that this should *not* be necessary, at least for non-rookie people.
Re:including header file
In a well-designed language (one which doesn't rely on a pre-processor for importing external interfaces) it shouldn't be a problem; we wouldn't have header files, but maybe something like Turbo Pascal units. However, that's what we're stuck with as long as we use C or C++, or an assembler with include statements.
Re:including header file
Thats somthing that was unclear to me at first. The inclution gards dont stop you include file from been included in all files, just stops in been included in one file.
Re:including header file
That's right. The inclusion guards are just there to prevent syntax errors from declaring the same things twice, not for stopping code and variables from being implemented more than once. You want several copies of declarations in the same program (otherwise you won't be able to join two modules together), but you only want one copy of each function or variable.