.h for standard headers

  • Thread starter Christopher Benson-Manica
  • Start date
C

Christopher Benson-Manica

At what point was the .h dropped from the STL headers? I just had a
discussion yesterday with my boss, who said he wanted .h on all the
STL includes, despite me protesting that it was not standard...
 
T

Tim Love

Christopher Benson-Manica said:
At what point was the .h dropped from the STL headers?
When ANSI C++ arrived, I think. When the STL was subsumed into the SL.
 
K

Karl Heinz Buchegger

Christopher said:
At what point was the .h dropped from the STL headers? I just had a
discussion yesterday with my boss, who said he wanted .h on all the
STL includes, despite me protesting that it was not standard...

In standard C++: Never
That is: .h was never a part of the standard includes.
All usages of eg. iostream.h date back to an era, where
'Standard C++' as defined today was nothing more then an
entry in a ToDo list. Some compiler vendors kept them
for compatibility even when 'The Standard' came into
existence.
 
C

Christopher Benson-Manica

Karl Heinz Buchegger said:
In standard C++: Never
That is: .h was never a part of the standard includes.
All usages of eg. iostream.h date back to an era, where
'Standard C++' as defined today was nothing more then an
entry in a ToDo list. Some compiler vendors kept them
for compatibility even when 'The Standard' came into
existence.

Did that era include, say, 1999?
 
P

Peter van Merkerk

Christopher Benson-Manica said:
Did that era include, say, 1999?

No, C++ was standardized in 1998. Adding .h to the standard header files
may mean that some day your code will no longer compile when you
change/upgrade your compiler and/or the standard library implementation.
That may very well be the motivation for your boss to insist on adding .h
to standard headers.
 
J

John Carson

Peter van Merkerk said:
No, C++ was standardized in 1998. Adding .h to the standard header
files may mean that some day your code will no longer compile when you
change/upgrade your compiler and/or the standard library
implementation.

That day is already here as far as VC++ 2003 is concerned.
 
H

Howard

Christopher Benson-Manica said:
At what point was the .h dropped from the STL headers? I just had a
discussion yesterday with my boss, who said he wanted .h on all the
STL includes, despite me protesting that it was not standard...

--

That's just silly. It's not a matter of style, or "common practice". It's
that the names of the files have changed. Some compilers still provide
headers with .h file extensions in their names, which (I believe) simply
include the non-.h version, but that's not required, and is likely to go
away entirely. And even now, if you want to include the file cstring, how
exactly is including cstring.h supposed to work when there is no such
file???

-Howard
 
J

John Ericson

Christopher Benson-Manica said:
Did that era include, say, 1999?
Flames welcome.

If you have legacy code using pre-Standard headers, it may
_require_ those pre-standard headers. I ran into that with
code that compiled with a particular <iostream.h>, but not
with <iostream>. God knows what happens if you mix headers,
but it sure wouldn't be anything good.
- -
JE
 
R

Rolf Magnus

Peter said:
No, C++ was standardized in 1998. Adding .h to the standard header
files may mean that some day your code will no longer compile when you
change/upgrade your compiler and/or the standard library
implementation. That may very well be the motivation for your boss to
insist on adding .h to standard headers.

I don't quite understand that statement. Why would the boss _want_ to
make sure that his programmers write code that will stop compiling on
modern compilers?
 
T

Tim Clacy

Christopher said:
At what point was the .h dropped from the STL headers? I just had a
discussion yesterday with my boss, who said he wanted .h on all the
STL includes, despite me protesting that it was not standard...

Presumably the idea of omitting an extension was thought up by someone who
doesn't use Windows; we have lost the conveniences of double clicking to
open and meaningful icon associations in one fell swoop.
 
J

Julie

Christopher said:
At what point was the .h dropped from the STL headers? I just had a
discussion yesterday with my boss, who said he wanted .h on all the
STL includes, despite me protesting that it was not standard...

1997/1998.

The compelling reason was that there wasn't a consensus on the appropriate C++
header extension (.h, .hpp, .hxx, ...), so it was agreed (not unanimously) to
drop the extension altogether.
 
J

Jeff Schwab

Tim said:
Presumably the idea of omitting an extension was thought up by someone who
doesn't use Windows; we have lost the conveniences of double clicking to
open and meaningful icon associations in one fell swoop.

Yeah, I'm crying my little heart out.

The new headers, unlike the old, place standard library constructs in
namespace std. Lots of legacy code already existed using the .h headers
and no namespace std. Having different names for the new (std-based)
headers allowed implementers to provide headers complying with the new
standard, without breaking the legacy code. For users of
implementations not providing the new headers, an easy work-around was
available:

// <iostream>

namespace std
{
#include <iostream.h>
}
 
T

Tim Clacy

Jeff said:
Yeah, I'm crying my little heart out.

...but seriously though, unless you're a hardened character-mode console
bashing hack, it is a pain not being able to easily identify or open header
files.
 
R

Rolf Magnus

Jeff said:
The new headers, unlike the old, place standard library constructs in
namespace std. Lots of legacy code already existed using the .h
headers and no namespace std. Having different names for the new
(std-based) headers allowed implementers to provide headers complying
with the new standard, without breaking the legacy code.

Which btw. brings up another point. The classes in the .h headers might
not be exactly the same as in the non-.h headers. So you might
experience surprises if you use the .h ones.
 
S

Stephen Howe

Christopher Benson-Manica said:
At what point was the .h dropped from the STL headers? I just had a
discussion yesterday with my boss, who said he wanted .h on all the
STL includes, despite me protesting that it was not standard...

Your boss needs re-educating.
Your boss should changes his views so that, "Whatever is standard C++, is
the company standard". That view will last a long time.

Stephen Howe
 
J

Jeff Schwab

Tim said:
..but seriously though, unless you're a hardened character-mode console
bashing hack, it is a pain not being able to easily identify or open header
files.

Well, I am pretty much a console-oriented kinda guy. However, I'm not
sure how relevant that is. I know what type of files are stored in
directories called "include", and my preferred editors can recognize
file-types based on names matching arbitrary patterns, not just the file
names' extensions.
 
P

P.J. Plauger

Christopher Benson-Manica asked:


You may have a problem with <string.h> (should it be the one containing
strcpy() or the std::string class ?)

According to Chuck Alison in the article "What's New in Standard C++"
(http://www.freshsources.com/newcpp.html), old style library headers are
deprecated ... here is the relevant quote:

Invoking Standard C Headers with a .h suffix
--------------------------------------------

We traditionally think of headers as files, but a compiler is free to make a
header's declarations available in any manner it chooses. To encourage this
point of view, the C++ standards committee voted rather early to drop the ..h
suffix for C++ headers. This means that you should use "#include <
iostream>" instead of "#include <iostream.h>", although most compilers will
allow both. When namespaces were added to the language, the committee
decided to wrap most C++ and all standard C library declarations in the
standard namespace std, and to rename the C headers by prepending a 'c' and
dropping the .h suffix. This means that the preferred method of getting at C
library features is the same for using C++ library elements, for example
#include <cstdio>

int main()
{
std::printf("hello, world\n");
}

Thinking that this might be too much of a culture shock, the committee
decided to deprecate instead of to disallow altogether the traditional ".h"
method. For now, if you say "#include <stdio.h>", it's as if you had written
"#include <cstdio>" followed by a using declaration for each identifier
defined in the header (so you don't have to use the std:: prefix).

True in theory, not always in practice.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 
C

Christopher Benson-Manica

Stephen Howe said:
Your boss needs re-educating.
Your boss should changes his views so that, "Whatever is standard C++, is
the company standard". That view will last a long time.

That's unlikely - I got chewed out yesterday because I changed a
global character array to a global string, and I've been all but
forbidden to use vectors, maps, and sets, not to mention strings. I
can't use streams at all because they don't work correctly, and I
can't count on other things working because our implementation is two
versions out of date. Yes, I've decided to find myself another job,
if I can :)
 

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
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top