From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22052 invoked by alias); 8 Oct 2012 10:27:22 -0000 Received: (qmail 22034 invoked by uid 22791); 8 Oct 2012 10:27:18 -0000 X-SWARE-Spam-Status: No, hits=-4.6 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 mailout05.t-online.de (HELO mailout05.t-online.de) (194.25.134.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Oct 2012 10:27:14 +0000 Received: from fwd15.aul.t-online.de (fwd15.aul.t-online.de ) by mailout05.t-online.de with smtp id 1TLAYL-0006yC-1O; Mon, 08 Oct 2012 12:27:13 +0200 Received: from [192.168.0.100] (Ss6c2yZErhf5SioUOOi+olB4+42zNCTMVDPuEIiZl9Pmwq6rLMB7V5w-Hu-8CYRQGA@[93.218.155.66]) by fwd15.t-online.de with esmtp id 1TLAYH-2IRbl20; Mon, 8 Oct 2012 12:27:09 +0200 Message-ID: <1349692028.21984.36.camel@yam-132-YW-E178-FTW> Subject: Re: 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:27:00 -0000 In-Reply-To: <133615603.20121008141915@gmail.com> References: <133615603.20121008141915@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/msg00043.txt.bz2 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? > No, another .o can't refer to this static function. Static functions are visible only in the translation unit where they are defined. The code above will generate a symbol reference to 'foo', i.e. a function call to a non-static function. If it is defined in some other .o and linked together, the 'foo' from the other .o will be used. Cheers, Oleg