From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11263 invoked by alias); 8 Oct 2012 10:43:21 -0000 Received: (qmail 11254 invoked by uid 22791); 8 Oct 2012 10:43:21 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout03.t-online.de (HELO mailout03.t-online.de) (194.25.134.81) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Oct 2012 10:43:17 +0000 Received: from fwd10.aul.t-online.de (fwd10.aul.t-online.de ) by mailout03.t-online.de with smtp id 1TLAnr-0005i1-1m; Mon, 08 Oct 2012 12:43:15 +0200 Received: from [192.168.0.100] (ES16avZaQhkU1HFLIJYaXKUCIkgiWFcZEUSi4BrkvxSRxK5vscxrVwA8LpR8ZIqQEZ@[93.218.155.66]) by fwd10.t-online.de with esmtp id 1TLAnm-0lOBZg0; Mon, 8 Oct 2012 12:43:10 +0200 Message-ID: <1349692989.21984.38.camel@yam-132-YW-E178-FTW> Subject: Re: Re[2]: Why "'X' used but never defined" is a warning and not error in gcc? From: Oleg Endo To: Ilya Basin Cc: gcc-help@gcc.gnu.org Date: Mon, 08 Oct 2012 10:43:00 -0000 In-Reply-To: <82245657.20121008143258@gmail.com> References: <133615603.20121008141915@gmail.com> <1349692028.21984.36.camel@yam-132-YW-E178-FTW> <82245657.20121008143258@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg00046.txt.bz2 On Mon, 2012-10-08 at 14:32 +0400, Ilya Basin wrote: > OE> On Mon, 2012-10-08 at 14:19 +0400, Ilya Basin wrote: > >> test.c: > >> static void foo(); > >> > >> void bar() { > >> foo(); > >> } > >> > >> $ gcc -c test.c > >> test.c:1: warning: 'foo' used but never defined > >> > >> Why warning and not error? Another *.o can refer this static function? > >> > > OE> No, another .o can't refer to this static function. Static functions > OE> are visible only in the translation unit where they are defined. > > OE> The code above will generate a symbol reference to 'foo', i.e. a > OE> function call to a non-static function. If it is defined in some > OE> other .o and linked together, the 'foo' from the other .o will be used. > > OE> Cheers, > OE> Oleg > > > Is there a flag to turn this warning into an error? Doesn't look so. You can turn all warnings into errors by -Werror, but there's no option to control this particular warning individually. > Is there a common > way to find the warning flag from a message? grep ;) Cheers, Oleg