From owner-freebsd-questions@FreeBSD.ORG Fri Dec 16 15:45:50 2005 Return-Path: X-Original-To: questions@freebsd.org 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 2A49916A41F for ; Fri, 16 Dec 2005 15:45:50 +0000 (GMT) (envelope-from FreeBSD@keyslapper.net) Received: from russian-caravan.cloud9.net (russian-caravan.cloud9.net [168.100.1.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA58743D5A for ; Fri, 16 Dec 2005 15:45:48 +0000 (GMT) (envelope-from FreeBSD@keyslapper.net) Received: from russian-caravan.cloud9.net (localhost [127.0.0.1]) by russian-caravan.cloud9.net (Postfix) with SMTP id 8AE3017B74; Fri, 16 Dec 2005 10:45:43 -0500 (EST) Received: from keyslapper.net (250-119.customer.cloud9.net [168.100.250.119]) by russian-caravan.cloud9.net (Postfix) with ESMTP id 0F92717B68; Fri, 16 Dec 2005 10:45:42 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by keyslapper.net (Postfix) with ESMTP id B318611712; Fri, 16 Dec 2005 10:41:15 -0500 (EST) Received: from keyslapper.net ([127.0.0.1]) by localhost (keyslapper.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00980-02; Fri, 16 Dec 2005 10:41:15 -0500 (EST) Received: from www.keyslapper.net (localhost [127.0.0.1]) by keyslapper.net (Postfix) with ESMTP id 65908114EE; Fri, 16 Dec 2005 10:41:15 -0500 (EST) Received: from 38.112.155.126 (SquirrelMail authenticated user leblanc) by www.keyslapper.net with HTTP; Fri, 16 Dec 2005 10:41:15 -0500 (EST) Message-ID: <9061.38.112.155.126.1134747675.squirrel@www.keyslapper.net> In-Reply-To: <43A2DE53.7080207@wmptl.com> References: <979f20140512160709n3530c01dmdad5714f8e30bc00@mail.gmail.com> <43A2DE53.7080207@wmptl.com> Date: Fri, 16 Dec 2005 10:41:15 -0500 (EST) From: "Louis J. LeBlanc" To: "Nathan Vidican" User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: amavisd-new at keyslapper.net Content-Transfer-Encoding: quoted-printable X-AntiVirus: Checked by Vexira Antivirus v1.5 Cc: David Miao , questions@freebsd.org Subject: Re: C++ compile error X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@FreeBSD.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 15:45:50 -0000 On Fri, December 16, 2005 10:33 am, Nathan Vidican wrote: > David Miao wrote: >> Dear list, >> >> I try to compile a hello world C++ program in FreeBSD 6.0, but get an >> error as below: >> >> [dm@ORION ~/cpp]% CC -o hello hello.C >> hello.C: In function `int main()': >> hello.C:5: error: `cout' undeclared (first use this function) >> hello.C:5: error: (Each undeclared identifier is reported only once >> for each function it appears in.) >> hello.C:5: error: `endl' undeclared (first use this function) >> >> I noticed that "iostream" file is located in >> "/usr/include/c++/3.4/iostream", I guess my CC compiler cannot find >> this head file. Is it true? And how can I fix this problem? Your >> advice is appreciated. Thanks in advance. >> >> =3D=3Dquote of hello world code=3D=3D >> #include >> >> int main() >> { >> cout << "Hello World!" << endl; >> >> return 0; >> } >> =3D=3D end of quote=3D=3D >> >> Regards, >> David >> _______________________________________________ >> freebsd-questions@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >> To unsubscribe, send any mail to >> "freebsd-questions-unsubscribe@freebsd.org" >> >> >> > > Also, noticed your code is flawed, you never used a namespace, nor > explicitly stated one. cout is part of the 'std' namespace, so either > ' using namespace std;' for global/local use of namespace, OR do > 'std::cout <<' instead. Try the hello.cpp I sent you in the last email, > that one should work for ya :) I'm not nearly as adept with C++ as I am with C, Perl, and a few other geek tools, but doesn't C++ default to the std namespace if none is specified? Perhaps this is a compiler specific behavior? Just curious. Lou --=20 Louis LeBlanc FreeBSD@keyslapper.net Fully Funded Hobbyist, KeySlapper Extrordinaire :=FE http://www.keyslapper.net =D4=BF=D4=AC