From owner-freebsd-questions@FreeBSD.ORG Tue Apr 11 22:57:50 2006 Return-Path: X-Original-To: freebsd-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 9748B16A403 for ; Tue, 11 Apr 2006 22:57:50 +0000 (UTC) (envelope-from nb_root@videotron.ca) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id D9B5143D45 for ; Tue, 11 Apr 2006 22:57:49 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from clk01a ([66.130.198.54]) by VL-MO-MR004.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0IXK009XHYG7E200@VL-MO-MR004.ip.videotron.ca> for freebsd-questions@freebsd.org; Tue, 11 Apr 2006 18:57:44 -0400 (EDT) Date: Tue, 11 Apr 2006 18:57:35 -0400 From: Nicolas Blais In-reply-to: <6a56d69c0604111554o587ce2c5ha1ff4ea20bbab0a4@mail.gmail.com> To: freebsd-questions@freebsd.org Message-id: <200604111857.43171.nb_root@videotron.ca> MIME-version: 1.0 Content-type: multipart/signed; boundary=nextPart1745095.jpJYJeOfra; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-transfer-encoding: 7bit References: <6a56d69c0604111554o587ce2c5ha1ff4ea20bbab0a4@mail.gmail.com> User-Agent: KMail/1.9.1 Cc: Jonathan Herriott Subject: Re: pow function working unexpectedly X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2006 22:57:50 -0000 --nextPart1745095.jpJYJeOfra Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Tuesday 11 April 2006 18:54, Jonathan Herriott wrote: > I just want to make sure I'm not being stupid before I send in a bug. > The problem seems to be with gcc when using the pow function in the > math.h library. Here's code that works: > > #include > #include > > int main() > { > printf("%f\n", pow(2,3)); > return 0; > } > > > Now, the following will not compile: > > #include > #include > > int main() > { > int x =3D 2; // I tried these as doubles too since the pow function > takes doubles > int y =3D 3; > > printf("%f\n", pow(x,y)); > return 0; > } > > I compiled both programs using: > gcc test.c > > The second example gives the following error: > > /var/tmp//ccxtkMwv.o(.text+0x45): In function `main': > : undefined reference to `pow' > > If I comile with g++, I have no issues. Are these results that I > should have? If so, why? If not, I'm going to submit the bug on gcc > (or the linker, but I'm guessing it's the same group). > > Thanks, > Jonathan Herriott gcc -lm test.c works. You forgot to include the math library. =2D-=20 =46reeBSD 7.0-CURRENT #1: Sat Apr 8 21:33:25 EDT 2006 =20 root@clk01a:/usr/obj/usr/src/sys/CLK01A=20 PGP? : http://www.clkroot.net/security/nb_root.asc --nextPart1745095.jpJYJeOfra Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (FreeBSD) iD8DBQBEPDRn4wTBlvcsbJURAsbvAJ97nVlNcjhfPULaypfa0OeGt0NoXgCcDrac 7Eu2Sm5RvI3U/Jf9eq/IcZ0= =ibUT -----END PGP SIGNATURE----- --nextPart1745095.jpJYJeOfra--