From owner-freebsd-questions@FreeBSD.ORG Wed Mar 2 17:17:56 2005 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 92CA716A4CE for ; Wed, 2 Mar 2005 17:17:56 +0000 (GMT) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id CF09943D49 for ; Wed, 2 Mar 2005 17:17:54 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])j22HHdOY005606; Wed, 2 Mar 2005 19:17:39 +0200 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) j22HHqm9005343; Wed, 2 Mar 2005 19:17:52 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)j22HHq5H005342; Wed, 2 Mar 2005 19:17:52 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Wed, 2 Mar 2005 19:17:52 +0200 From: Giorgos Keramidas To: Florian Hengstberger Message-ID: <20050302171752.GA5229@orion.daedalusnetworks.priv> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: cc: freebsd-questions@freebsd.org Subject: Re: c standard 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: Wed, 02 Mar 2005 17:17:56 -0000 On 2005-03-02 17:13, Florian Hengstberger wrote: > Following is possible with gcc and g++: > > #include > > double sin(double) > { > return 1; > } > > int main() > { > sin(1); > return 1; > } > > Why I don't get any warnings like: > > sin prevously defined in math.h ... > > when I compile with -Wall -pedantic -ansi. Are you sure? It fails to compile here: $ cc -std=c89 -pedantic sin.c sin.c: In function `sin': sin.c:3: error: parameter name omitted $ cc -std=c99 -pedantic sin.c sin.c: In function `sin': sin.c:3: error: parameter name omitted > Why is it possible to overwrite the definition of sin, is this part of > the standard? There is no definition of sin() at that point. Only a declaration (i.e. a prototype of the function). Your definition happens to match the visible prototype, so it accepts your custom definition of sin(). > Secondly the definition (not declaration) of double sin(double) misses > a variable! Is this ok, when the variable is not referenced in the > code? This is not ok, as far as I can tell from the warnings above.