ios and other

P

Philip Lawatsch

Hi,

I'm trying to clean up our code (way over a million lines).
This code has been there for some years, with lots of different (and
sometimes lazy) developers, and thus is a complete mess.

For instance we're mixing old and new iostreams, which might be legal,
but definitely not a good idea.

Now my question, has anybody ever done such a thing ?
What in particular should i try to do ?

I tried search and replacing stuff like #include <iostream.h> to
#include <iostream>, and same for most other headers i know.

Is there a list of all the old / new headers for ios ?

Or, is there even a list for headers i should / should not use to have
std compliant code ?

(Thinking about avoiding os specific / compiler specific headers)

with kind regards Philip
 
M

Mike Wahler

Philip Lawatsch said:
Hi,

I'm trying to clean up our code (way over a million lines).
This code has been there for some years, with lots of different (and
sometimes lazy) developers, and thus is a complete mess.

For instance we're mixing old and new iostreams, which might be legal,
but definitely not a good idea.

Now my question, has anybody ever done such a thing ?
Yss.

What in particular should i try to do ?

That depends upon your goals.
I tried search and replacing stuff like #include <iostream.h> to
#include <iostream>, and same for most other headers i know.

Did you also qualify the library identifiers with their
namespace?
Is there a list of all the old / new headers for ios ?

There is a list of all standard C++ headers -- cited
in the ISO standard, and in many textbooks.
Or, is there even a list for headers i should / should not use to have
std compliant code ?

Use only the ones specified by the standard, otherwise
it's not 'standard'.
(Thinking about avoiding os specific / compiler specific headers)

Anything not on the 'list' is compiler/platform specific,
or 'third party'.


Some pertinent portions of the ISO standard:

=== begin quote ====

ISO/IEC 14882:1998(E)

17.4.1.2 Headers

1 The elements of the C++ Standard Library are declared or defined
(as appropriate) in a header. (158)

2 The C++ Standard Library provides 32 C++ headers, as shown in
Table 11:

Table 11 -- C++ Library Headers

<algorithm> <iomanip> <list> <ostream> <streambuf>
<bitset> <ios> <locale> <queue> <string>
<complex> <iosfwd> <map> <set> <typeinfo>
<deque> <iostream> <memory> <sstream> <utility>
<exception> <istream> <new> <stack> <valarray>
<fstream> <iterator> <numeric> <stdexcept> <vector>
<functional> <limits>

3 The facilities of the Standard C Library are provided in 18
additional headers, as shown in Table 12:

Table 12 -- C++ Headers for C Library Facilities

<cassert> <ciso646> <csetjmp> <cstdio> <ctime>
<cctype> <climits> <csignal> <cstdlib> <cwchar>
<cerrno> <clocale> <cstdarg> <cstring> <cwctype>
<cfloat> <cmath> <cstddef>

4 Except as noted in clauses 18 through 27, the contents of each header
cname shall be the same as that of the corresponding header name.h,
as specified in ISO/IEC 9899:1990 Programming Languages C (Clause 7),
or ISO/IEC:1990 Programming Languages -- C AMENDMENT 1: C Integrity,
(Clause 7), as appropriate, as if by inclusion. In the C++ Standard
Library, however, the declarations and definitions (except for names
which are defined as macros in C) are within namespace scope (3.3.5)
of the namespace std.

5 Names which are defined as macros in C shall be defined as macros in
the C++ Standard Library, even if C grants license for implementation
as functions. [Note: the names defined as macros in C include the fol­
lowing: assert, errno, offsetof, setjmp, va_arg, va_end, and va_start.
-- end note]

6 Names that are defined as functions in C shall be defined as functions
in the C++ Standard Library. (159)

7 D.5, Standard C library headers, describes the effects of using the
name.h (C header) form in a C++ program. (160)

(158) A header is not necessarily a source file, nor are the sequences
delimited by < and > in header names necessarily valid source file
names (16.2).

(159) This disallows the practice, allowed in C, of providing a "masking
macro" in addition to the function prototype. The only way to achieve
equivalent "inline" behavior in C++ is to provide a definition as an
extern inline function.

(160) The ".h" headers dump all their names into the global namespace,
whereas the newer forms keep their names in namespace std. Therefore,
the newer forms are the preferred forms for all uses except for C++
programs which are intended to be strictly compatible with C.

[,,,]

D.5 Standard C library headers

1 For compatibility with the Standard C library, the C++
Standard library provides the 18 C headers, as shown in
Table 100:

Table 100 -- C Headers

<assert.h> <iso646.h> <setjmp.h> <stdio.h> <wchar.h>
<ctype.h> <limits.h> <signal.h> <stdlib.h> <wctype.h>
<errno.h> <locale.h> <stdarg.h> <string.h>
<float.h> <math.h> <stddef.h> <time.h>

2 Each C header, whose name has the form name.h, behaves as if
each name placed in the Standard library namespace by the
corresponding cname header is also placed within the namespace
scope of the name­space std and is followed by an explicit
using­declaration (7.3.3)

3 [Example: The header <cstdlib> provides its declarations and
definitions within the namespace std. The header <stdlib.h>
makes these available in the global name space, much as in
the C Standard. -- end example]

=== end quote ====

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top