Talk:Header file

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing  
WikiProject icon This redirect is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 ???  This redirect does not require a rating on the project's quality scale.
 

Merge or not?[edit]

Headline to thread was missing. I invented an appropriate one. --Netizen (talk) 21:34, 29 November 2008 (UTC)
Keeping header file separate seems appropriate. Akihabara 14:53, 11 July 2005 (UTC)

I don't think the resulting article would be long because there is a good deal of overlap between this and C preprocessor. Besides, when the article gets really long in future, we can split it into two. -- Taku 23:39, July 11, 2005 (UTC)
Indeed it is only short because it is incomplete. It is nonsensical to merge the two, because someone would then have to read through information not related to what they are after. An encyclopedia should give people the information they are looking for efficiently merging these articles would not be efficient. Further joining the articles to then later split them up sounds like a brilliant exercise in wasting time, large corporations would be proud of you. elandra 21:53, 15 July 2005 (UTC)
I agree. This term certainly stands on its own. There is no reason to combine it with the preprocessor article. Especially since header files are found in other languages other than those using the C preprocessor. Mrmcgibby 23:07, 29 July 2005 (UTC)
I say keep them seperate.--Lewk_of_Serthic 18:57, August 23, 2005 (UTC)
Unless someone objects in the next day or so, I'm going to remove the merge notice.--Lewk_of_Serthic 13:50, August 30, 2005 (UTC)
I was not logged in, but I deleted the merge notice.--Lewk_of_Serthic 19:10, August 31, 2005 (UTC)


examples of header file[edit]

copyvio[edit]

I think big chunks of this must be a copyvio. Look at this sentence: "Please note that the code segments provided above are in no way the best way to do the projects." Whenever this big slab was inserted, that edit should be reverted. 128.250.37.103 06:46, 11 August 2006 (UTC)

I wrote the examples from scratch. I was trying to come up with the simplest example that illustrates the point of header files. I might have had a poor attempt at doing so, however there is no copyright infringement. If you find a copy of this example elsewhere, then that might be a copyright infringement against me! Please ask the authors of the articles before making accusations based on your intuitions. Thank you. BardiaM 12:38, December 29 2006 (MT)

Include in programB.c[edit]

  • I am no expert on the subject, so my question could be silly... but, shouldn't the last programB.c read #include "programA.c" instead of #include "programA.h"? — Isilanes 19:54, 30 April 2007 (UTC)
  • No. Header (.h) files are included in other files. C source files (.c), as a rule, are not. Pfaffben 14:17, 2 May 2007 (UTC)

Dubious statement[edit]

"interfaces in Java are analogous to C header files" seems suspect to me. The two are surely quite different ideas? —Preceding unsigned comment added by 193.113.57.163 (talkcontribs)

They're not totally different, in that C header files are typically used to publish public interfaces, and Java interfaces are typically used to describe public interfaces. They are different "parts of speech", so to speak, since header files contain source code, whereas the Java interface is a construct which appears in source code. In any case, I've made massive changes that included deleting that sentence. Java is mentioned farther up the page, with more finesse. :) --Quuxplusone 06:13, 7 June 2007 (UTC)

Reverted intro[edit]

Derek farn's old intro:

In computer programming, particularly in the C and C++ programming languages, a header file or include file is a file, usually in the form of source code, which is intended to be processed by a compiler when another source file is compiled. The header file is referenced within the source file by using some computer language directive, usually containing the word include. A common convention is that the name of a header file name include the letter h in its suffix, eg., .h, hpp.

My reversion:

In computer programming, particularly in the C and C++ programming languages, a header file or include file is a file that is automatically included in another source file in order to provide forward declarations for subroutines or variables used in the latter file. Typically, header files are included via compiler directives at the beginning (or head) of the other source file.

Reasons I think the latter is better:

  • "usually in the form of source code" — As far as I know, header files are by definition "source code", since they're processed by a compiler (or assembler), and therefore cannot be called "executable code". So this is redundant, but masks its redundancy with the weasel word "usually".
There is no requirement in C or C++ for headers to be source code (not so sure about other languages) and in some implementations they have the form of a precompiled binary file (this can speed up compilation significantly when headers are large). Derek farn 10:57, 11 June 2007 (UTC)
  • "referenced" — is not a word. (Nitpicky, yes.)
Not a word in whose dictionary? Derek farn 10:57, 11 June 2007 (UTC)
Directive is the term used by many language specifications. The directive article could use some work, otherwise it looks fine to me, the usage is not a compiler directive. Derek farn 10:57, 11 June 2007 (UTC)
  • "usually containing the word include" — Improper use of bold HTML tags. "Usually" is a vague weasel word here; the writer might mean "only in C and C++", or "in all languages except Java and Perl", or something in between; I can't tell. It's hard to tell what's "usually" done in programming languages, because the set of programming languages is not well defined.
Yes, usually is vague here. Some languages use #include, others $include and others %include, and I am sure there are other combinations. The essence is that most contain the letters include (there are a few languages that use other words). Derek farn 10:57, 11 June 2007 (UTC)
  • "A common convention is that the name of a header file name include the letter h in its suffix" — Totally ungrammatical. Besides, this is a rule only in C. In C++, the standard headers do not have any file extension (although admittedly most user-defined header files use ".h" as a holdover from C). One (or even one-and-a-half) out of two isn't really "common".
Ok, it may be ungrammatical, but it is technically correct. Fix the grammar. Derek farn 10:57, 11 June 2007 (UTC)

--Quuxplusone 03:30, 11 June 2007 (UTC)

Oh, well, if you want to rebut some of my points, I'll make a longer list. :) You say "compiler directive" is not accurate, but you write "intended to be processed by a compiler when another source file is compiled", which implies that compilers are being used here. The first sentence of the article is unnecessarily densely worded. The one-sentence paragraphs on which I did not previously comment also contain grammatical errors, which your reversion re-introduced. I disagree that header files are used "to hold automatically generated code", although included non-header files occasionally are. Please do not blindly revert changes; take a look at what's written and see if you can improve it, or use some of its improvements in your own revision.

Have a nice day! --Quuxplusone 17:46, 11 June 2007 (UTC)

Thanks[edit]

Nice! This article sure helped me alot in understanding how header files works in c++. I wish to thank the editors alot! Solved a 2h headache.

213.112.109.129 11:48, 21 July 2007 (UTC)

Doubt[edit]

How do you display the contents of a header file using a c++ program??


Curieous 17:46, 08 Feb 2008 (UTC)

Java/C# - "naming scheme"[edit]

The page says that newer languages do no need header files because of a special naming scheme. What kind of special naming scheme is it? Java one-file-per-class? In C# I do not need to use any special naming scheme, it just works when I write class A{ public int f(){return 0;}} in any source file. It does not "restrict file-naming freedom" 217.75.59.233 (talk) 13:32, 19 August 2009 (UTC)

Naming scheme has nothing to do with not requiring header files. It is all about compiler being smart enough to generate (keep) function and class list internally. 217.75.59.233 (talk) 13:35, 19 August 2009 (UTC)

Interface? What interface?[edit]

The following sentence in this article is written presumptively: "This is to keep the interface in the header separate from the implementation." As a first-time reader of this topic, I'm immediately wondering, "What interface?" I come here to try to understand what a header file is, and this sentence suddenly throws at me that there is some interface within headers. What? In all headers? Are headers something that contain "interfaces"? If so, what the hell is meant by an interface? If headers always or usually have "interfaces" in them, then shouldn't the article first state this and immediately explain what an "interface" is? That wasn't meant to be (too) harsh, but contributors should check their own edits for such levels of presumption, and do so as if what they have written were being read by someone unfamiliar with the encompassing subject. — Preceding unsigned comment added by 109.145.82.159 (talk) 08:42, 19 August 2011 (UTC)

The following sentence in this article is written assumptively: "This is to keep the interface in the header separate from the implementation." As a first-time reader of this topic, I'm immediately wondering, "What interface?" I come here to try to understand what a header file is, and this sentence suddenly throws at me that there is some interface within headers. What? In all headers? Are headers something that contain "interfaces"? If so, what the hell is meant by an interface? If headers always or usually have "interfaces" in them, then shouldn't the article first state this and immediately explain what an "interface" is? That wasn't meant to be (too) harsh, but contributors should check their own edits for such levels of presumption, and do so as if what they have written were being read by someone unfamiliar with the encompassing subject. — Preceding unsigned comment added by 109.145.82.159 (talk) 08:43, 19 August 2011 (UTC)

Reference[edit]

Can somebody please provide a live link to this reference http://archive.gamedev.net/reference/programming/features/orgfiles/page2.asp .This link is dead. Jobin (talk) 12:22, 10 September 2011 (UTC)