|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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.
__________________
Jason Doucette / Xona.com™ - Programming Windows Errata Addendum "Discussion is an exchange of knowledge; argument is an exchange of ignorance." |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
||||
|
||||
|
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 |
|
#4
|
||||
|
||||
|
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++. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Difference between #include <cxxx> and <xxx.h>? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|