help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about namespace std in 2.95 to 3.0 upgrade


From: Chris Maxwell
Subject: Question about namespace std in 2.95 to 3.0 upgrade
Date: Mon, 8 Apr 2002 19:27:02 -0300
User-agent: Mutt/1.2.5i

  Recently I finally upgraded our G++ from 2.95.x to 3.0.3.  

  It has been a while since I actually wrote alot of C++ code (before STL 
to be precise), so when a whole bunch of students showed up complaining that 
I had broken their code I was surprised.  The code looked reasonable, but 
they were using this new syntax for includes:

#include <iostream> 

  that I had not seen before.  They claimed that it worked fine before 
the upgrade as

----------------------------------------------------------------------
#include <iostream> 

/* using namespace std; <==== this was not here */

int main () {
    cout << "Hello World!" << endl;
    return 0;
}
----------------------------------------------------------------------
  but now it was saying that cout and endl were not defined even though
they had included the iostream "library"(sic).

  As it turns out when I found a GCC 2.95.2 compiler, it does indeed 
compile this without complaint.  Now it does not in 3.0.x.  I now know that 
this "new syntax" is ANSI C++, and that they were violating it by 
leaving off the "using namespace std", but I am just wondering if 
anyone has a comment on this change, eg whether there is anything in 
the release notes saying "WARNING this will break your damaged code.
We supported a deprecated "feature", now we do not!", as I could not find 
any.  

Am I correct in tell them to just stick in "using namespace std"?
How much of a violation is it to leave off the namespace thing?
Is there a compiler switch I can tell them to use since they are 
so insistent that this is absolutely correct, it has always worked, it 
should work, etc?  

  Anyway, thank you very much for any help you can give,

-- 
  Chris Maxwell
  Unix SysAdmin, Faculty of Computer Science, 
  Dalhousie University, Halifax, Nova Scotia, Canada
  (902) 494-1369 / chris.maxwell@dal.ca / FAX: (902) 492-1517



reply via email to

[Prev in Thread] Current Thread [Next in Thread]