This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re[2]: Why "'X' used but never defined" is a warning and not error in gcc?
- From: Ilya Basin <basinilya at gmail dot com>
- To: Oleg Endo <oleg dot endo at t-online dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 8 Oct 2012 14:32:58 +0400
- Subject: Re[2]: Why "'X' used but never defined" is a warning and not error in gcc?
- References: <133615603.20121008141915@gmail.com> <1349692028.21984.36.camel@yam-132-YW-E178-FTW>
- Reply-to: Ilya Basin <basinilya at gmail dot com>
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? Is there a common
way to find the warning flag from a message?
--