.h for standard headers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Benson-Manica

    .h for standard headers

    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...

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
  • Tim Love

    #2
    Re: .h for standard headers

    Christopher Benson-Manica <ataru@nospam.c yberspace.org> writes:
    [color=blue]
    >At what point was the .h dropped from the STL headers?[/color]
    When ANSI C++ arrived, I think. When the STL was subsumed into the SL.

    Comment

    • Karl Heinz Buchegger

      #3
      Re: .h for standard headers

      Christopher Benson-Manica wrote:[color=blue]
      >
      > 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...
      >[/color]

      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.

      --
      Karl Heinz Buchegger
      kbuchegg@gascad .at

      Comment

      • Christopher Benson-Manica

        #4
        Re: .h for standard headers

        Karl Heinz Buchegger <kbuchegg@gasca d.at> spoke thus:
        [color=blue]
        > 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.[/color]

        Did that era include, say, 1999?

        --
        Christopher Benson-Manica | I *should* know what I'm talking about - if I
        ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

        Comment

        • Sharad Kala

          #5
          Re: .h for standard headers


          "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in message
          news:c8d422$s69 $1@chessie.cirr .com...[color=blue]
          > Karl Heinz Buchegger <kbuchegg@gasca d.at> spoke thus:
          >
          > Did that era include, say, 1999?[/color]

          The standard was ratified in 1997 and became official in1998.


          Comment

          • Karl Heinz Buchegger

            #6
            Re: .h for standard headers

            Christopher Benson-Manica wrote:[color=blue]
            >
            > Karl Heinz Buchegger <kbuchegg@gasca d.at> spoke thus:
            >[color=green]
            > > 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.[/color]
            >
            > Did that era include, say, 1999?[/color]

            If I recall correctly, the first version of the Standard
            was published 1998

            --
            Karl Heinz Buchegger
            kbuchegg@gascad .at

            Comment

            • Peter van Merkerk

              #7
              Re: .h for standard headers

              "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in message
              news:c8d422$s69 $1@chessie.cirr .com...[color=blue]
              > Karl Heinz Buchegger <kbuchegg@gasca d.at> spoke thus:
              >[color=green]
              > > 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.[/color]
              >
              > Did that era include, say, 1999?[/color]

              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.
              --
              Peter van Merkerk
              peter.van.merke rk(at)dse.nl


              Comment

              • John Carson

                #8
                Re: .h for standard headers

                "Peter van Merkerk" <merkerk@deadsp am.com> wrote in message
                news:2guk10F6g1 skU1@uni-berlin.de[color=blue]
                >
                > 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.[/color]

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


                --
                John Carson
                1. To reply to email address, remove donald
                2. Don't reply to email address (post here instead)

                Comment

                • Howard

                  #9
                  Re: .h for standard headers


                  "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in message
                  news:c8d33k$rsl $1@chessie.cirr .com...[color=blue]
                  > 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...
                  >
                  > --[/color]

                  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


                  Comment

                  • John Ericson

                    #10
                    Re: .h for standard headers


                    "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org>
                    wrote in message news:c8d422$s69 $1@chessie.cirr .com...[color=blue]
                    > Karl Heinz Buchegger <kbuchegg@gasca d.at> spoke thus:
                    >[color=green]
                    > > 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.[/color]
                    >
                    > Did that era include, say, 1999?
                    >
                    > --
                    > Christopher Benson-Manica | I *should* know what I'm[/color]
                    talking about - if I[color=blue]
                    > ataru(at)cybers pace.org | don't, I need to know.[/color]
                    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


                    Comment

                    • David Fisher

                      #11
                      Re: .h for standard headers

                      Christopher Benson-Manica asked:
                      [color=blue]
                      > 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...[/color]

                      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("he llo, 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).

                      David Fisher
                      Sydney, Australia


                      Comment

                      • Rolf Magnus

                        #12
                        Re: .h for standard headers

                        Peter van Merkerk wrote:
                        [color=blue][color=green]
                        >> Did that era include, say, 1999?[/color]
                        >
                        > 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.[/color]

                        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?

                        Comment

                        • Tim Clacy

                          #13
                          Re: .h for standard headers

                          Christopher Benson-Manica wrote:[color=blue]
                          > 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...[/color]

                          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.


                          Comment

                          • Julie

                            #14
                            Re: .h for standard headers

                            Christopher Benson-Manica wrote:[color=blue]
                            >
                            > 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...[/color]

                            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.

                            Comment

                            • Jeff Schwab

                              #15
                              Re: .h for standard headers

                              Tim Clacy wrote:[color=blue]
                              > Christopher Benson-Manica wrote:
                              >[color=green]
                              >>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...[/color]
                              >
                              >
                              > 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.[/color]

                              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>
                              }

                              Comment

                              Working...