Thread: include question

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    33

    include question

    why do i keep reading about not using .h at the end of the #include <whatever.h>?

    i am using Microsoft Visual studio 6 and when i take out the .h i get this error:

    c:\program files\microsoft visual studio\myprojects\ftp\ftp.cpp(56) : fatal error C1010: unexpected end of file while looking for precompiled header directive

    i am not sure if it has anything to with it but it might. I still get errors with the .h but none like this one. Also may i ask why when i asked a ? about ending a process it was sent to another board? The program was in c++. well thanks and if you know anything about how to end a process in c++ please let me know..i cant figure it out..i am using TerminateProcess() and i get errors so thanks for any help

  2. #2
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    With C++, some #includes such as iostream are not always targeting a file named iostream.h (I believe.) Sometimes you have to put .h, other times you don't. Not sure if that is your problem, but it seems like it might be.
    Do not make direct eye contact with me.

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Before the most recent C++ standard, most compilers provided libraries like iostream.h, fstream.h and iomanip.h with the '.h' extension. When the standard became standard, they decided to put all the stuff in those header files into the std namespace, and the new headers that follow the standard don't have the '.h' extension.

    Also, the standard C library has the headers like stdio.h, stdlib.h, math.h and time.h. With the new C++ standard, those header files were deprecated (they are still allowed for now, but might not be supported in the future). Instead, the new header files were created without the '.h' and with an extra 'c' at the beginning, like cstdio, cstdlib, cmath and ctime.

    So, in general, you should use the ones without the .h, because they are the standard headers.

    Here are the headers that my STL library implementation has. When there are two possible headers to use, I put the ones you should use in blue and the ones you should avoid in red. The ones in black are new to the C++ standard and are of course good to use also.

    The Standard C++ library consists of 51 required headers. This implementation also includes three additional headers, <hash_map>, <hash_set>, and <slist>, not required by the C++ Standard, for a total of 54 headers. Of these 54 headers, 16 constitute the Standard Template Library, or STL. These are indicated below with the notation (STL):

    <algorithm> -- (STL) for defining numerous templates that implement useful algorithms
    <bitset> -- for defining a template class that administers sets of bits
    <complex> -- for defining a template class that supports complex arithmetic
    <deque> -- (STL) for defining a template class that implements a deque container
    <exception> -- for defining several functions that control exception handling
    <fstream> -- for defining several iostreams template classes that manipulate exteral files
    <functional> -- (STL) for defining several templates that help construct predicates for the templates defined in <algorithm> and <numeric>
    <map> -- (STL) for defining template classes that implement hashed associative containers that map keys to values
    <hash_set> -- (STL) for defining template classes that implement hashed associative containers
    <iomanip> -- for declaring several iostreams manipulators that take an argument
    <ios> -- for defining the template class that serves as the base for many iostreams classes
    <iosfwd> -- for declaring several iostreams template classes before they are necessarily defined
    <iostream> -- for declaring the iostreams objects that manipulate the standard streams
    <istream> -- for defining the template class that performs extractions
    <iterator> -- (STL) for defining several templates that help define and manipulate iterators
    <limits> -- for testing numeric type properties
    <list> -- (STL) for defining a template class that implements a doubly linked list container
    <locale> -- for defining several classes and templates that control locale-specific behavior, as in the iostreams classes
    <map> -- (STL) for defining template classes that implement associative containers that map keys to values
    <memory> -- (STL) for defining several templates that allocate and free storage for various container classes
    <new> -- for declaring several functions that allocate and free storage
    <numeric> -- (STL) for defining several templates that implement useful numeric functions
    <ostream> -- for defining the template class that performs insertions
    <queue> -- (STL) for defining a template class that implements a queue container
    <set> -- (STL) for defining template classes that implement associative containers
    <slist> -- (STL) for defining a template class that implements a singly linked list container
    <sstream> -- for defining several iostreams template classes that manipulate string containers
    <stack> -- (STL) for defining a template class that implements a stack container
    <stdexcept> -- for defining several classes useful for reporting exceptions
    <streambuf> -- for defining template classes that buffer iostreams operations
    <string> -- for defining a template class that implements a string container
    <strstream> -- for defining several iostreams classes that manipulate in-memory character sequences
    <typeinfo> -- for defining class type_info, the result of the typeid operator
    <utility> -- (STL) for defining several templates of general utility
    <valarray> -- for defining several classes and template classes that support value-oriented arrays
    <vector> -- (STL) for defining a template class that implements a vector container

    The Standard C++ library works in conjunction with the 18 headers from the Standard C library, sometimes with small alterations. The headers come in two forms, new and traditional. The new-form headers are:

    <cassert> -- for enforcing assertions when functions execute
    <cctype> -- for classifying characters
    <cerrno> -- for testing error codes reported by library functions
    <cfloat> -- for testing floating-point type properties
    <ciso646> -- for programming in ISO 646 variant character sets
    <climits> -- for testing integer type properties
    <clocale> -- for adapting to different cultural conventions
    <cmath> -- for computing common mathematical functions
    <csetjmp> -- for executing nonlocal goto statements
    <csignal> -- for controlling various exceptional conditions
    <cstdarg> -- for accessing a varying number of arguments
    <cstddef> -- for defining several useful types and macros
    <cstdio> -- for performing input and output
    <cstdlib> -- for performing a variety of operations
    <cstring> -- for manipulating several kinds of strings
    <ctime> -- for converting between various time and date formats
    <cwchar> -- for manipulating wide streams and several kinds of strings
    <cwctype> -- for classifying wide characters

    The traditional Standard C library headers are:

    <assert.h> -- for enforcing assertions when functions execute
    <ctype.h> -- for classifying characters
    <errno.h> -- for testing error codes reported by library functions
    <float.h> -- for testing floating-point type properties
    <iso646.h> -- for programming in ISO 646 variant character sets
    <limits.h> -- for testing integer type properties
    <locale.h> -- for adapting to different cultural conventions
    <math.h> -- for computing common mathematical functions
    <setjmp.h> -- for executing nonlocal goto statements
    <signal.h> -- for controlling various exceptional conditions
    <stdarg.h> -- for accessing a varying number of arguments
    <stddef.h> -- for defining several useful types and macros
    <stdio.h> -- for performing input and output
    <stdlib.h> -- for performing a variety of operations
    <string.h> -- for manipulating several kinds of strings
    <time.h> -- for converting between various time and date formats
    <wchar.h> -- for manipulating wide streams and several kinds of strings
    <wctype.h> -- for classifying wide characters

    Finally, in this implementation, the Standard C++ library also includes several headers for compatibility with traditional C++ libraries:

    <fstream.h> -- for defining several iostreams template classes that manipulate exteral files
    <iomanip.h> -- for declaring several iostreams manipulators that take an argument
    <iostream.h> -- for declaring the iostreams objects that manipulate the standard streams
    <new.h> -- for declaring several functions that allocate and free storage
    <stl.h> -- for declaring several template classes that aid migration from older versions of the Standard Template Library
    I'm not really an expert, but I'm pretty sure this is the explanation.

    Don't remove the '.h' on any header unless it is part of the standard library (one of the headers up there). Normal headers that you write or others write usually do have the '.h' or '.hpp'.
    Last edited by jlou; 10-15-2003 at 11:59 AM.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    1,619

    Re: include question

    Originally posted by Wanted420


    c:\program files\microsoft visual studio\myprojects\ftp\ftp.cpp(56) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    This error means you probably messed with stdafx.h, the precompiled header file.

    You can simply turn off precompiled headers for the project in the project options; I never really use them, I don't think they're really a time saving optimization for most work, and they can mess up other #includes. Personally I wish I could make PCH default to off.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    33
    Hey i just wanted to say thanks for all the info.

  6. #6
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    Hey all,

    Does anyone know when the next revision of the standard is likely to happen (or is it already happening)?
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  7. #7
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Well, they always discuss it. I'd estimate 2005 maybe? 2006?

    Hopefully they include most of Boost (they should, Boost is made by most of the same people)
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  8. #8
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    Sorry Cat, what is Boost?
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  9. #9
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Precompiled header question
    By donglee in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2009, 01:23 AM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Socket Question
    By DaveHope in forum Networking/Device Communication
    Replies: 12
    Last Post: 06-21-2005, 04:50 PM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM