Steve Youngs <steve@xxxxxxxxxxx> writes:
> * Zajcev Evgeny <zevlg@xxxxxxxxx> writes:
>
> > Steve Youngs <steve@xxxxxxxxxxx> writes:
> >> * Zajcev Evgeny <zevlg@xxxxxxxxx> writes:
> >> > It is not critical thing that you ommit some cases declared in
> >> > enum type, but sometimes useful to track error when you forgot to
> >> > handle some condidion which you've declared in enum type. So
> >> > -Wno-swich can be considered as fix.
> >>
> >> OK, so we add `-Wno-switch' to the "hard-coded" (in the Makefile.in)
> >> compiler flags and everyone's happy. Until one day someone introduces
> >> a bug that _NOT_ having this flag set may have alerted the person who
> >> introduced the bug that his code had a bug.
> >>
> >> See what I'm getting at?
>
> > ok, normally to avoid such warning - avoid using enum type at all.
> > But it is stupid. Any other(fixing code) solution is worse than
> > -Wno-switch.
>
> > Ok, what if we will have TAG_CFLAGS to build tag programs and CFLAGS
> > to build other programs. TAG_CFLAGS will include -Wno-switch and
> > CFLAGS wont?
>
> > BTW: such bugs are easy to catch, even eisier than fixing existing
> > code to avoid warnings.
>
> Evgeny, I am shocked and astounded. Please explain to me why the
> answer isn't something like...
>
> Find out if these unused thingies really are unused and delete
> them. And if for some strange bazaar reason they really are used
> but because of some weird voodoo the compiler thinks they aren't,
> find a way to show the compiler "the light" _*WITHOUT RESORTING TO
> EXTRA CFLAGS*_.
Hey man! Compilers are stupid! this is an axiom. They can't read
mind as you can. They just process sources to other sources.
Fixing(no, modifying) etags just for gcc satisfaction is stupid.
Code(concerning using enum type in switch statement) written ideally
correctly, if someone think that it is wrong - shut up it with
-Wno-switch. Patch which only shutups gcc without -Wno-switch will
cost aproximately 130 lines of code which does *NOTHING*, literally
*NOTHING* - useless code at all, why we need useless code? Remember
that perfect thing is not when there is nothing to add, but when there
is nothing to remove.
If you really want to fix it - add to each switch statement every
instant of enum type, for example:
enum {
one, two,thee, four
} tttt;
switch (ttt) {
case one:
/* useful code here */
break;
case two:
/* useful code here */
break;
/* no more useful cases */
}
on this, gcc -Wswitch will throw warnings, to stop gcc doing so,
modify it to look like:
enum {
one, two,thee,four
} tttt;
switch (ttt) {
case one:
/* useful code here */
break;
case two:
/* useful code here */
break;
/*
* List other cases, which useless, but makes gcc to be
* satisfied.
*/
case three:
case four:
/* DO NOTHING */
break;
}
Thats it.
>
> Evgeny, I know that you have probably forgotten more about C than I'll
> ever know, but lets not just give in on this and hide things behind
> CFLAGS or anything else.
>
> As a complete novice where C is concerned, I view _any_ warning as
> bad. I'm not a novice where elisp is concerned, and I view _any_
> warning as bad. I honestly believe that all software should compile
> totally error and warning free.
No, any warning is not a bad. It is bad for compiler that it
interprets normal situation as warningable. But it is understandable
that developers does not spent their time writing AI module
Thanks!
--
lg
|