Re: [OT] What is a 'header' file?
- Posted by Matt Lewis <matthewwalkerlewis at gmail??om> Jun 04, 2008
- 740 views
Derek Parnell wrote: > > ZNorQ wrote: > > > > I'm not quite sure what a header file is. > > Header files are used by the C and C++ languages. <snip> > Then, when the compiler comes across a reference to an object of the class > 'Bar', > it knows enough to check that the reference is valid. > > Header files are useful for single pass compilers because it means that it can > deal easily with forward references. > > Header files are not needed for multiple pass compilers. Yeah, but it's a bit more than that, because to build a C/C++ executable, compiling isn't enough. Basically, the compiler compiles each .c/cpp/etc file into an object file, then it links them all together. Before the linking, none of the object files really know about each other, except from what they've heard from header files. Some of the references might also be resolved to dynamic/shared libraries. Matt