Hello,
In my day, we made something called a "makefile" in order to bind it all together. Do a search on makefiles.... I have not built one in quite some time.
I also believe that when the compiler makes the first pass, and sees the .h file referenced, it simply adds that file's text to the main program. I don't think it makes it into a .o and then links them things together. I thought that the compiler command simply hauled the text into a compiler, and then let the dogs loose.
Do not quote me; it has been some time since school.
Christian
kc0arf
Posting Virtuoso
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
headerfiles are not compiled, clear and simple.
.o files are compiled compilation units which have not yet been linked, header files are not compilation units.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
headerfiles are not compiled, clear and simple.
.o files are compiled compilation units which have not yet been linked, header files are not compilation units.
That's my understanding too, but a couple of weeks ago I asked a question in this forum about a header file like this:
// header file
#ifndef NUMBERS.H
#define NUMBERS.H
// Some typical header file stuff
#endif
My question was what are the first two lines about. I was told that their purpose was to avoid mutiple compilations. But header files are not compiled!
I should be asking the person who posted the answer to my question, but I don't remeber who that was or what thread it was on. Perhaps you can answer it.
By the way, the header files that come with my compiler, bcc32, have a lot of these "#ifndefine" statements.
murschech
Junior Poster in Training
60 posts since Dec 2004
Reputation Points: 21
Solved Threads: 1
My question was what are the first two lines about. I was told that their purpose was to avoid mutiple compilations.
Perhaps you remember it wrong -- was it to "[post=81677]prevent multipleinclusion[/post]"?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Perhaps you remember it wrong -- was it to "[post=81677]prevent multiple inclusion[/post]"?
Yes, I can see how preventing multiple inclusions would work. (I do think the previous respondant said "multiple compilations", but that's not important) Thank you.
While I'm taking advantage of your knowledge, could yu tell me what a "pragma" is?
murschech
Junior Poster in Training
60 posts since Dec 2004
Reputation Points: 21
Solved Threads: 1
Yes, I can see how preventing multiple inclusions would work. (I do think the previous respondant said "multiple compilations", but that's not important) Thank you.
Uh, follow the link. The "previous respondant" was me, and no I did not say "multiple compilations".It prevents multiple inclusion of the header.While I'm taking advantage of your knowledge, could yu tell me what a "pragma" is?A preprocessing directive which causes the implementation to behave in an implementation-defined manner. The behavior might cause translation to fail or cause the translator or the resulting program to behave in a non-conforming manner. Any such pragma that is not recognized by the implementation is ignored.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314