How the header files work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Firecore
    New Member
    • Jul 2007
    • 114

    How the header files work

    Hi guys
    How exactly do the header files like iostream.h and stdio.h actually work?
    Where is the source code for these files located?
    Is it possible to read it?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    The header file just contain declarations of functions and types and constants required to call the interface they define. Typically the code for these functions exists in the C/C++ run time library which is normally automatically linked by the linker.

    The library is binary, depending on your platform the source for this library may or may not be shipped with the compiler although it is shipped more and more often these days.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Also, stdio.h is a C header. C++ uses cstdio.

      Also, iostream.h is the pre-ANSI C++ used prior to Sept 1998. You should be using iostream.

      Comment

      • Firecore
        New Member
        • Jul 2007
        • 114

        #4
        Originally posted by Banfa
        The header file just contain declarations of functions and types and constants required to call the interface they define. Typically the code for these functions exists in the C/C++ run time library which is normally automatically linked by the linker.

        The library is binary, depending on your platform the source for this library may or may not be shipped with the compiler although it is shipped more and more often these days.
        Is it possible to create our own libraries?

        Comment

        • oler1s
          Recognized Expert Contributor
          • Aug 2007
          • 671

          #5
          Sure, and in any non-trivial project, you will be using multiple third party libraries as well as making and using your own.

          A library is just pre-written code than can be reused for whatever reasons. You can either ship the source code outright, or give it out as OS specific binary files, along with supporting files for compilation such as headers.

          Comment

          • Firecore
            New Member
            • Jul 2007
            • 114

            #6
            Originally posted by oler1s
            Sure, and in any non-trivial project, you will be using multiple third party libraries as well as making and using your own.

            A library is just pre-written code than can be reused for whatever reasons. You can either ship the source code outright, or give it out as OS specific binary files, along with supporting files for compilation such as headers.
            Could you show me how to do create a sample library, that does say add two numbers or something of the sort?

            Comment

            • smalpani
              New Member
              • Aug 2007
              • 29

              #7
              Originally posted by Firecore
              Could you show me how to do create a sample library, that does say add two numbers or something of the sort?
              http://www.unet.univie .ac.at/aix/aixprggd/genprogc/create_shared_l ib.htm


              a little bit of google always helps

              Comment

              Working...