2

In http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf only header is mentioned.

In https://github.com/cplusplus/draft/blob/master/papers/n4727.pdf header file appears twice:

[ Note: The non-member functions enable programmers to write code that can be compiled as either C or C++, for example in a shared header file. — end note ]


Difficulty of converting: Semantic transformation. The type definitions must be moved to file scope, or in header files

Edit: let's see the note in n4727:

A header is not necessarily a source file, nor are the sequences delimited by < and > in header names necessarily valid source file names.

So, I still think they are different concepts.

My question is, what's the difference between header and header file? Now that header is not necessarily a source file, what else can it be?

Chen Li
  • 4,824
  • 3
  • 28
  • 55
  • 9
    Same thing. Just slightly different terminology. – Steve Summit Feb 25 '18 at 14:23
  • @SteveSummit please review my updates – Chen Li Feb 25 '18 at 14:36
  • Even if there is _terminological_ difference .. that would be weakened by the fact that everything in c++ must and would converge to either header files `.hxx` and _source .cxx_ files .. be comfortable thinking no difference! – Mohammad Kanan Feb 25 '18 at 15:02
  • 1
    @MohammadKanan -- this is a `language-lawyer` question. The intent is to interrogate the Standard, not fall back on common implementation details. – ad absurdum Feb 25 '18 at 15:07
  • @DavidBowling, I lean to consider this implementation .. otherwise _standard_ must take care of that – Mohammad Kanan Feb 25 '18 at 15:13
  • @DavidBowling My defense is this comment from _Deduplicator_: _The standard headers are part of the **implementation**, and found in an implementation-defined manner. They could, in theory, be part of the compiler (and not files in the filesystem) .._ – Mohammad Kanan Feb 25 '18 at 15:17
  • 1
    @czxyl If you're worried about headers-that-might-not-be-files, the [linked question](https://stackoverflow.com/questions/27261508/is-a-header-necessarily-a-file) explains it well. (That question is tagged C++, but I think most/all of it applies to C.) It's probably to admit the possibility they might not be files that some authors take care to call them *headers*, but it's still the same concept. – Steve Summit Feb 25 '18 at 15:20
  • @MohammadKanan -- Yes, headers are part of the implementation, but the Standard does not appear to require that they be _files_. This is what OP is asking about. "Be comfortable thinking no difference" is probably fine, but doesn't address OP question which seeks further understanding. – ad absurdum Feb 25 '18 at 15:28
  • @DavidBowling, yes if they could be _for instance_ part of the compiler .. or ..anything where it would be possible to _include_ them – Mohammad Kanan Feb 25 '18 at 15:32
  • 1
    Neither of your citations is normative: one is a note, and the other is in an informative Annex. So formally there is no ground for claiming they are different. Practically speaking, those passages address _application programmers_, who cannot make non-file headers. – Davis Herring Feb 25 '18 at 15:33
  • 2
    @DavisHerring -- "formally there is no ground for claiming they are different": formally there are no reasons form claiming they are the same. [This answer from the duplicate provides an enlightening quote from the C99 Rationale](https://stackoverflow.com/a/27262904/6879826). – ad absurdum Feb 25 '18 at 15:48
  • 1
    @DavidBowling: My phrasing was careless. The right thing to say is that, normatively, there is no phrase “header file” about which to ask the question. – Davis Herring Feb 25 '18 at 18:10

0 Answers0