#1
  1. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12

    Difference between #include <cxxx> and <xxx.h>?


    What are the precise differences between:

    #include <cstdio>
    vs
    #include <stdio.h>

    (or <cassert> vs <assert.h>)? I used to know, but my memory is failing me.

    I always include the .h file, but I know that including the library name includes the .h file, anyway - so what is the difference?

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    272
    Rep Power
    18
    There isn't a great deal of difference in the two examples you gave. cassert does nothing more than #include <assert.h>. cstdio does a #include <stdio.h> as well as redefining a symbol if it thinks it needs to. I am in the habit of always using the .h files directly so I really can't comment on when you might want to use one rather than the other.
  4. #3
  5. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Italy -> Naples
    Posts
    9
    Rep Power
    0

    Lightbulb header files


    cstdio is the C++ version of the C header stdio.h .
    its contents are (mostly) the same as that header, but are all contained in the namespace std.

    if u use linux u can observ differences editing
    /usr/include/stdio.h
    and
    /usr/include/c++/x.x.x/cstido
    where x.x.x. is the version of your compiler
  6. #4
  7. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    3dfxMM, yes, I am in the habit of just including the .h files, as well, so I had no idea what the differences were. I never had a problem with just the plain .h files.

    M3xican, thanks for your reply. I have taken a look at the cstdio file, and it does just include the stdio.h file, like I expected. So, basically, if you are using C++, the proper file to include would be the cxxxx file, without the .h postfix, so they are contained within their proper namespaces, which was introduced in C++.

IMN logo majestic logo threadwatch logo seochat tools logo