This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Minor installation bug


At 12:16 AM 2/14/98 -0500, Richard Hadsell wrote:
>Pablo Halpern wrote:
>> 
>> fstream
>> iomanip
>> istream
>> ostream
>> streambuf
>> 
>> Each of these was easily created by creating a one-line file that #includes
>> the old-fashoned name (which should remain for backwards-compatability).  In
>> other words, file fstream should contain the single line:
>> 
>> #include <fstream.h>
>
>You might consider the scheme that KAI uses to help people make the
>transition to the std:: namespace for the C++ Standard Library.  Their
><xxx> headers obey the standard, declaring everything in std::.  For
>those who are not ready for that, they also have <xxx.h> headers, which
>include <xxx> and then export the appropriate names to the global
>namespace via using commands.  I think an idea along these lines was
>mentioned recently with regard to namespaces.

IMHO, this is the "right" way to go. However, the egcs compiler does not yet
support namespaces, so this won't work for the time being.

>Also, you don't want to create some trivial form of header that is still
>not up to the standard.  It might be better at this point to hold off on
><xxx> headers until you can make them a lot closer to the standard.

The STL headers, <vector>, <set>, <algorithm>, etc. as well as <string> are
all currently supported without the .h.  It seems inconsistent and confusing
to not also support the headers listed above. That is why I reported this as
a bug, not a wish-list item.

Except for the user of namespace std, I think the above headers are
reasonably close to the standard in the way most people use them. (Format
flags, manipulators, constructors, file-opening functions, etc. are all
almost exactly adherent to the standard.))  It would be a waste of effort to
use the .h now and then change every file to remove the .h in the future. I
used to put this kind of stuff in my .C files:

#ifdef OLDSTYLE_HEADERS
#include <iostream.h>
#else
#include <iostream>
#endif

But now I just create the appropriate .h-less wrappers when needed for the
specific compiler. It really makes the code easier to read. The namespace
stuff is trickier, but the following in my Makefile helps:

CCFLAGS=-Dstd  etc....

This defines std as an empty macro so that std::cout is munged by the
preprocessor to ::cout, which is correct for compilers that don't support
namespaces.

- Pablo

---------------------------------------------------------------------
Pablo Halpern                                    phalpern@newview.org



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]