#### Archived

This topic is now archived and is closed to further replies.

# if the reason they change iostream.h to iostream...

This topic is 5074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

is for a compatibility purpose, why didn''t they do that for other header files as well? Why do some header files require .h? Yes, I do find the .h tag is quite unnecessary.

##### Share on other sites
Most of the headers I've used that are of the standard had prior .h counterparts. fstream is one that comes to mind right now. String has a string.h. math.h should be replaced with cmath and so on.

[edited by - nervo on March 29, 2004 9:54:44 PM]

##### Share on other sites
None of the standard headers in C++ require the .h extension.

If you write your own header or someone else supplies the header, you/they are free to give it whatever extension you/they feel like.

##### Share on other sites
quote:
Original post by SiCrane
If you write your own header or someone else supplies the header, you/they are free to give it whatever extension you/they feel like.
But why don''t they make it a standard too that the all header files shouldn''t have the .h extension? They did that with C++ standard header files.

##### Share on other sites
It is important to note that string.h became cstring, which is completely different than string

string.h/cstring: strlen, strcmp, etc.
string: STL''s basic_string, string

##### Share on other sites
quote:
Original post by alnite
But why don''t they make it a standard too that the all header files shouldn''t have the .h extension?
If you want a real revolution, ask them to get rid of header files once and for all.

##### Share on other sites
quote:
Original post by alnite
But why don''t they make it a standard too that the all header files shouldn''t have the .h extension? They did that with C++ standard header files.

Why should they? If I want to call my headers "somefile.h" or even "somefile.cow", what right does the standards committe have to say that I can''t? The standards committee doesn''t have any jurisdiction over my private code libraries.

##### Share on other sites
Why don''t they get rid of the .cpp extension as well?

##### Share on other sites
They took off the .h for all of the standard C++ headers I believe, as others have mentioned. People still use .h because a) it''s a handy convention and b) C still uses .h.

The C++ standard doesn''t affect the C standard and lots of people still use C, you know. But most people use .h when making headers because it''s just plain useful.

##### Share on other sites
quote:
Original post by SiCrane
quote:
Original post by alnite
But why don''t they make it a standard too that the all header files shouldn''t have the .h extension? They did that with C++ standard header files.

Why should they? If I want to call my headers "somefile.h" or even "somefile.cow", what right does the standards committe have to say that I can''t? The standards committee doesn''t have any jurisdiction over my private code libraries.
Well, that sounds like a valid reason.

@Roland
then there is no way of knowing which file is a C++ source.

##### Share on other sites
quote:
Original post by antareus
Hm..true.

The reason I ask is because everybody else, in books, tutorials, classrooms, etc, have been saying "if you want to make a class make a .h and a .cpp" etc etc. When I first learnt it I didn't complain, but now, typing .h every time I want to use a class is just tedious. It feels so much better to include C++ standard headers just because they don't have that extra .h extension.

#include <vector> // yay!
The name says it all that I am using the vector class.

#include "myclass.h" // huh!?
That .h somehow makes the whole thing ugly.

[edited by - alnite on March 29, 2004 11:09:23 PM]

##### Share on other sites
i like the ".h" because it allows windows to label my files as "Header File" in the explorer...

##### Share on other sites
Note: That some people like using .hpp for there C++ headers.

##### Share on other sites
quote:
Original post by alnite
When I first learnt it I didn''t complain, but now, typing .h every time I want to use a class is just tedious.
Heh, if you think that typing two extra letters rarely is tedious, I wonder how you''d feel if you learnt a language that requires less than half the code your average C++ program does to do the same job.. Most everything in C++ is tedious and you complain about the minorest thing. That''s kind of funny.

##### Share on other sites
quote:
Original post by Oluseyi
quote:
Original post by alnite
But why don''t they make it a standard too that the all header files shouldn''t have the .h extension?
If you want a real revolution, ask them to get rid of header files once and for all.

+5

##### Share on other sites
cilcoder> Yes, I use .hpp and .cpp. But as soon as I work with a team, everybody is confused

But did you see an editor which creates both header and source file and which creates a "headername" or a "headername.cpp" ?

##### Share on other sites
I guess it''s a useful convention for header files to have some filename "extension" on, even if it''s just for the benefit of Windows Explorer.

iostream and its friends do not; but then again does it matter? A rose by any other name...

Boost''s header files are all called .hpp, and it''s a well respected set of C++ libraries.

So we have .h, .hpp and <iostream> but does it really matter. Most programmers will either copy & paste #include lines in, have them generated by a tool, or put them inside a precompiled header (stdafx.h or something by default on MSVC?). So it''s not really a big battle.

Mark

##### Share on other sites
i prefer the original .C and .H extensions for C++. Even better, get rid of all extensions and use a real filesystem that can store mimetypes for files!

##### Share on other sites
Which filesystems do that?

##### Share on other sites
quote:
Original post by Kylotan
Which filesystems do that?
Not MIME types, but files on the Mac have internal IDS. Their extensions are largely decorative.

Or at least, they used to be. With OS X, Apple has capitulated to the Windows-esque convention of interpreting extension as type for many file types.

##### Share on other sites
hmmm... i was browsing through my "include" folder (i use bcc55), and noticed that there are no header files without the ".h" extension. i guess when you leave it off in your #include statement it is added anyway, and changes something else (a #define maybe) so it uses the std version stuff...

##### Share on other sites
quote:
Original post by Oluseyi With OS X, Apple has capitulated to the Windows-esque convention of interpreting extension as type for many file types.

You''d think that everything on OSX would be a UNIX-esque convention, since OSX is... well... UNIX.

quote:
Even better, get rid of all extensions and use a real filesystem that can store mimetypes for files!

Correct me if I''m wrong (I probably am), but isn''t the MIME type for .h and .cpp files text/plain?

##### Share on other sites
According to the lecturer at uni.

The reason that the c++ standard no longer requires the library header files to be labeled ".h" is because that implies a text file. Essentially it''s so that someone releasing a library can release precompiled headers for their library (although the compiler would have to support it).