Re: Re[2]: Why "'X' used but never defined" is a warning and not error in gcc?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux