www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/02/05/10:38:56

Message-ID: <20030205153840.3916.qmail@web13008.mail.yahoo.com>
Date: Wed, 5 Feb 2003 07:38:40 -0800 (PST)
From: Thomas Tutone <thomas8675309 AT yahoo DOT com>
Subject: Re: new install question for 3.21
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

"Drew" <drew AT drew DOT com> wrote: 

> I just upgraded from the old 2.72 version of DJGPP 
> to the newest version 3.21.

Wow, that was an old version you had.

> All my exisiting C and C++ programs compile and run 
> fine but I get an 
> information message that I never got before when I 
> compile.
> 
> The message is:
> 
> In file included from 
> c:/djgpp/lang/cxx/3.21/backward/iostream.h:31,
>                  from maketree.cpp:6:
> c:/djgpp/lang/cxx/3.21/backward/ 
> backward_warning.h:32:
> 2: warning: 
> #warning This file includes at least one deprecated 
> or antiquated 
> header. Please consider usin
> g one of the 32 headers found in section 17.4.1.2 
> of the C++ standard.
> Examples
> include substituting the <X> header for the <X.h> 
> header for C++
> includes, or <s
> stream> instead of the deprecated header 
> <strstream.h>. To disable
> this warning
> use -Wno-deprecated.
> The program still runs fine....I'm just not sure 
> how to correct this 
> message.  If I just say #include <iostream>, the 
> compile generates 
> lots of errors as it doesn't find cout and the 
> functions.
> 
> Should I just use the command flags to suppress it 
> or what?
> 

Get an up-to-date C++ textbook, which will explain the
difference between <iostream> and <iostream.h>. 
Briefly, in 1998, the C++ standard was adopted.  Among
other things, it introduced the concept of namespaces.
 All standard library functions, objects, and classes
are now in namespace std.  This means that what used
to be known as cout is now actually std::cout (which
is why you got those error messages).  It is defined
in <iostream>.  The headers your old code uses, like
<iostream.h>, do not conform to the standard.  

Since version 3.0, GCC (and therefore DJGPP) have
conformed to the standard in this respect, but have
kept in the old-style headers as well so that old code
would not be broken.

If you are going to be modifying the code and using
other parts of the standard library, the best course
probably is for you to bring the code up to date.  I
would also do that for any new code you write, so that
your new code conforms to the standard.  But for your
existing code, you have a couple choices.

Quick and dirty solution:  You can change to the
proper headers (like <iostream>), and at the beginning
of each .cpp file add:

using namespace std;

But, if the code works OK as is using the deprecated
headers (like <iostream.h>), and you're not modifying
the code, you may want to just leave it as is rather
than change it.  The standard headers can differ from
the old-style headers in obscure ways, and if it ain't
broke, perhaps better not to try to fix it.  In that
case, you may as well suppress the warning using the
command line option.  But I wouldn't get in the habit
of doing so.  For any new code, compile with all
warnings on:

gxx -W -Wall -pedantic -o foo.exe foo.cpp

Best regards,

Tom

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019