What is a header?

  • Thread starter Steven T. Hatton
  • Start date
S

Steven T. Hatton

If a header is not necessarily a source file, and the sequences delimited by
< and > in header names aren't necessarily valid source file names, what
exactly is a header?
 
M

Mike Wahler

Steven T. Hatton said:
If a header is not necessarily a source file, and the sequences delimited by
< and > in header names aren't necessarily valid source file names, what
exactly is a header?

A set of declarations. The actual ultimate source of
these declarations is unspecified. It's typically
a file (often with the same name).

-Mike
 
P

Pete Vidler

Steven said:
If a header is not necessarily a source file, and the sequences delimited by
< and > in header names aren't necessarily valid source file names, what
exactly is a header?

From a compiler's perspective they don't exist. The preprocessor
combines source and header files (via #include) into translation units.

It's just a programmer convenience. It makes it easier to refer to
common code between translation units by including all the
interfaces/declarations into both.

Everything else you'll see in there is simply the convention (or coding
standards) that were used to write the program. Like where on the line
you indent or put braces.

-- Pete
 
J

Julie

Steven T. Hatton said:
If a header is not necessarily a source file, and the sequences delimited by
< and > in header names aren't necessarily valid source file names, what
exactly is a header?

A header is _necessarily_ a source file that is exclusively distinctly visible
by the preprocessor.
 
S

Steven T. Hatton

Julie said:
A header is _necessarily_ a source file that is exclusively distinctly
visible by the preprocessor.
"A header is not necessarily a source file, nor are the sequences delimited
by < and > in header names necessarily valid source file names (16.2)."
ISO/IEC 14882:2003(E)
 
K

Kevin Goodsell

Julie said:
A header is _necessarily_ a source file that is exclusively distinctly visible
by the preprocessor.

2.8 Header names [lex.header]
header-name:
<h-char-sequence>
"q-char-sequence"
h-char-sequence:
h-char
h-char-sequence h-char
h-char:
any member of the source character set except
new-line and >
q-char-sequence:
q-char
q-char-sequence q-char
q-char:
any member of the source character set except
new-line and "

1 Header name preprocessing tokens shall only appear within a #include
preprocessing directive (_cpp.include_). The sequences in both forms
of header-names are mapped in an implementation-defined manner to
headers or to external source file names as specified in
_cpp.include_.



16.2 Source file inclusion [cpp.include]

1 A #include directive shall identify a header or source file that can
be processed by the implementation.

2 A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header
identified uniquely by the specified sequence between the < and >
delimiters, and causes the replacement of that directive by the entire
contents of the header. How the places are specified or the header
identified is implementation-defined.


I don't see anything here requiring headers to be files. In fact, it
sounds like they went out of their way to make sure that was not implied
(e.g., "header _or_ source file").

-Kevin
 
J

Julie

Steven T. Hatton said:
"A header is not necessarily a source file, nor are the sequences delimited
by < and > in header names necessarily valid source file names (16.2)."
ISO/IEC 14882:2003(E)

I would have preferred you posting that with your original post.
 
S

Steven T. Hatton

Kevin said:
I don't see anything here requiring headers to be files. In fact, it
sounds like they went out of their way to make sure that was not implied
(e.g., "header _or_ source file").

I have the feeling there is some ancient dark secret surrounding this issue
that none of the oldtimers wants to talk about. I tried to ask about the
history of research into alternatives to the traditional header file on
comp.std.c++, but received no reply.
 
A

Alf P. Steinbach

* "Steven T. Hatton said:
I have the feeling there is some ancient dark secret surrounding this issue
that none of the oldtimers wants to talk about.

No dark secrets.

I tried to ask about the
history of research into alternatives to the traditional header file on
comp.std.c++, but received no reply.

The current wording allows an implementation to implement standard
headers in other and perhaps more efficient ways than using files, like
like having e.g. <string> hardwired into the compiler.

Because of that it also allows non-file-based headers in general.

But as far as I know there are no commonly used implementations taking
advantage of this. In terms of designing the standard it's like the common
error of adding complexity to a class in order to support some imagined
future need which never actually materializes. So perhaps what you think
of as the "oldtimers" in [comp.std.c++] simply were a bit ashamed, or even
simpler, didn't think this important enough to waste time on.
 
S

Steven T. Hatton

Alf said:
* "Steven T. Hatton said:
I have the feeling there is some ancient dark secret surrounding this
issue that none of the oldtimers wants to talk about.

No dark secrets.

I tried to ask about the
history of research into alternatives to the traditional header file on
comp.std.c++, but received no reply.

The current wording allows an implementation to implement standard
headers in other and perhaps more efficient ways than using files, like
like having e.g. <string> hardwired into the compiler.

Because of that it also allows non-file-based headers in general.

But as far as I know there are no commonly used implementations taking
advantage of this. In terms of designing the standard it's like the
common error of adding complexity to a class in order to support some
imagined
future need which never actually materializes. So perhaps what you think
of as the "oldtimers" in [comp.std.c++] simply were a bit ashamed, or even
simpler, didn't think this important enough to waste time on.

There's an interesting epigraph at the beginning of chapter 18 in
TC++PL(SE). Form is liberating. - engineers' proverb.
 
J

John Doe

I have the feeling there is some ancient dark secret surrounding this issue
that none of the oldtimers wants to talk about. I tried to ask about the
history of research into alternatives to the traditional header file on
comp.std.c++, but received no reply.

People here and in comp.std.c++ volunteer their free time to participate
in discussions they find interesting. If you don't get an answer to your
posts, it's either because a) there's a great conspiracy against you or
b) your question was not regarded as something worth spending time on.

Now, which of the two alternatives do you think is the more likely one?

//JD
 
S

Steven T. Hatton

John said:
People here and in comp.std.c++ volunteer their free time to participate
in discussions they find interesting. If you don't get an answer to your
posts, it's either because a) there's a great conspiracy against you or
b) your question was not regarded as something worth spending time on.

Now, which of the two alternatives do you think is the more likely one?

//JD

Actually there's more to it than just posting the question once. But, like I
said, it's just a feeling.
 
L

Leor Zolman

I would have preferred you posting that with your original post.

The OP doesn't seem to believe in providing more information than it takes
in order for him to be able to understand his own questions. Or, he just
phrases questions in a way that misrepresents the level he's approaching
the issue from; whether he's doing this to deliberately draw folks who are
earnestly trying to help him into making errors he can "poach", or he just
takes opportunities when they arise to demonstrate what he possibly thinks
of as his superior intellect, I can't say. I do, however, now find myself
embarrassed to be seen in the same thread with him (I would have preferred
to email this to you directly, but you don't give out your address.)
-leor
 
S

Steven T. Hatton

Leor Zolman wrote:

The OP doesn't seem to believe in providing more information than it takes
in order for him to be able to understand his own questions. Or, he just
phrases questions in a way that misrepresents the level he's approaching
the issue from;
Hu?

whether he's doing this to deliberately draw folks who are
earnestly trying to help him into making errors he can "poach",

Na, I only take fair game.
 
F

Frosted Flake

The OP doesn't seem to believe in providing more information than it takes
in order for him to be able to understand his own questions. Or, he just
phrases questions in a way that misrepresents the level he's approaching
the issue from; whether he's doing this to deliberately draw folks who are
earnestly trying to help him into making errors he can "poach", or he just
takes opportunities when they arise to demonstrate what he possibly thinks
of as his superior intellect, I can't say. I do, however, now find myself
embarrassed to be seen in the same thread with him (I would have preferred
to email this to you directly, but you don't give out your address.)
-leor

It might be useful to layout what was said.

Mr Hatton's first post:
If a header is not necessarily a source file, and the sequences delimited by
< and > in header names aren't necessarily valid source file names, what
exactly is a header?

2nd: (Note the same wording as above)
"A header is not necessarily a source file, nor are the sequences delimited
by < and > in header names necessarily valid source file names (16.2)."
ISO/IEC 14882:2003(E)

3rd:
I have the feeling there is some ancient dark secret surrounding this issue
that none of the oldtimers wants to talk about. I tried to ask about the
history of research into alternatives to the traditional header file on
comp.std.c++, but received no reply.

4th:
There's an interesting epigraph at the beginning of chapter 18 in
TC++PL(SE). Form is liberating. - engineers' proverb.

5th:
Actually there's more to it than just posting the question once. But, like I
said, it's just a feeling.
 
S

Steven T. Hatton

Frosted said:
Mr Hatton's first post:
If a header is not necessarily a source file, and the sequences delimited
by < and > in header names aren't necessarily valid source file names,
what exactly is a header?

2nd: (Note the same wording as above)
"A header is not necessarily a source file, nor are the sequences
delimited by < and > in header names necessarily valid source file names
(16.2)." ISO/IEC 14882:2003(E)

3rd:
I have the feeling there is some ancient dark secret surrounding this
issue that none of the oldtimers wants to talk about. I tried to ask about
the history of research into alternatives to the traditional header file
on comp.std.c++, but received no reply.

4th:
There's an interesting epigraph at the beginning of chapter 18 in
TC++PL(SE). Form is liberating. - engineers' proverb.

5th:
Actually there's more to it than just posting the question once. But, like
I said, it's just a feeling.

So what is this? Your idea of one-upsmanship? Try harder next time. You're
dealing with a pro.
 
F

Frosted Flake

Steve,
I'm sorry I meant this to show there didn't seem to be anything
to what the guy was saying about about poaching. Sometimes
what people remember is not how it is when you take
another look. I hope you understand.
 
S

Steven T. Hatton

Frosted said:
Steve,
I'm sorry I meant this to show there didn't seem to be anything
to what the guy was saying about about poaching. Sometimes
what people remember is not how it is when you take
another look. I hope you understand.

No problem. I was just having fun with obscurity. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top