From owner-freebsd-questions@FreeBSD.ORG Mon Apr 21 03:33:39 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 218D537B401 for ; Mon, 21 Apr 2003 03:33:39 -0700 (PDT) Received: from falcon.midgard.homeip.net (h76n3fls20o913.telia.com [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id B79CD43FA3 for ; Mon, 21 Apr 2003 03:33:36 -0700 (PDT) (envelope-from ertr1013@student.uu.se) Received: (qmail 92776 invoked by uid 1001); 21 Apr 2003 10:33:35 -0000 Date: Mon, 21 Apr 2003 12:33:35 +0200 From: Erik Trulsson To: Jason Griffis Message-ID: <20030421103334.GA92718@falcon.midgard.homeip.net> Mail-Followup-To: Jason Griffis , freebsd-questions@freebsd.org References: <200304210539.11227.jgriffis@ec.rr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200304210539.11227.jgriffis@ec.rr.com> User-Agent: Mutt/1.5.4i cc: freebsd-questions@freebsd.org Subject: Re: g++ question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2003 10:33:39 -0000 On Mon, Apr 21, 2003 at 05:39:11AM -0400, Jason Griffis wrote: > I'm going through a C++ tutorial trying to increase my knowledge ;) > Any way.. I wrote this little code: > > // My first program in C++ > #include > > int main() > { > cout << "Hello World!"; > return 0; > } > > When I compile it this way with g++ I get errors due to the compiler not > finding the iostream file: > > $ g++ -o hello hello.cc > hello.cc: In function `int main()': > hello.cc:6: `cout' undeclared (first use this function) > hello.cc:6: (Each undeclared identifier is reported only once for each > function > it appears in.) > $ > > I do have iostream in /usr/include so I don't see why it's doing this, > whenever I change it to #include it compiles fine but gives a > warning of using a deprecated header file: > > $ g++ -o hello hello.cc > In file included from /usr/include/g++/backward/iostream.h:31, > from hello.cc:2: > /usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file > includes at least one deprecated or antiquated header. Please consider using > one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples > include substituting the header for the header for C++ includes, or > instead of the deprecated header . To disable this > warning use -Wno-deprecated. > $ > > Obviously it isn't that big of a deal with such a small program but when I > move on to bigger projects that I'll want to use on different platforms other > than FreeBSD these errors and warnings will be a major pain. Can anyone tell > me what might be wrong with my system in order for g++ not to see the normal > iostream header in /usr/include ? [This is not really a FreeBSD question, but rather a C++ question.] Nothing wrong with your system, but a problem with your program. The tutorial you are using seems to be a bit old. Although your program would have been just fine with older C++ implementations (except that they did not have headernames of the style, only ) , the newer, standard-compliant, implementations have moved most of the standard library into the 'std' namespace. The older name for the headers puts the functions into the global namespace, but that is not recommended for new code. Try using std::cout instead of just cout. (Or put a 'using namespace std;' after the include.) -- Erik Trulsson ertr1013@student.uu.se