From owner-freebsd-questions@FreeBSD.ORG Tue Nov 29 13:33:28 2005 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 E646616A41F for ; Tue, 29 Nov 2005 13:33:28 +0000 (GMT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from mail25.sea5.speakeasy.net (mail25.sea5.speakeasy.net [69.17.117.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id C8A0843D55 for ; Tue, 29 Nov 2005 13:33:27 +0000 (GMT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: (qmail 4936 invoked from network); 29 Nov 2005 13:33:27 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail25.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 29 Nov 2005 13:33:27 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id 2F68E28424; Tue, 29 Nov 2005 08:33:26 -0500 (EST) Sender: lowell@be-well.ilk.org To: Mamta BANSAL References: <438AAD0F.90205@st.com> From: Lowell Gilbert Date: 29 Nov 2005 08:33:25 -0500 In-Reply-To: <438AAD0F.90205@st.com> Message-ID: <441x0zlgt6.fsf@be-well.ilk.org> Lines: 32 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@freebsd.org Subject: Re: questions about gcc options 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: Tue, 29 Nov 2005 13:33:29 -0000 Mamta BANSAL writes: > Hello > for a c code i am using gcc compiler. > i have doubt using -c option. > for a c code the code compiles (without error ) with -c option even if > i don't provide prior declaration of function. > i mean i have try.c > //******************* > > void my_func( ){ > call_to_undeclared_func( ); > } > //******************** > i do : gcc -c try.c , it works. > is it the correct behaviour , i mean should it not ask for atleast > declearation of call_to_undeclared_func( ); > > like if my make the same as try.cpp then usen use the same command it > gives the foll. error.: > > try.cpp: In function `void my_func()': > try.cpp:2: implicit declaration of function `int > call_to_undeclared_func(...)' > which i feel is expected behaviour. That doesn't require a diagnostic in C, but it does in C++. If you want the diagnostics anyway, use the -Wimplicit-function-declaration flag to the compiler. Or -Wall, which adds a pretty extensive set of non-required warnings. See the gcc manual if you want more information.