| Subject: | Re: case labels |
|---|---|
| From: | CBFalconer |
| Date: | Sun, 30 Mar 2008 08:51:08 -0500 |
| Newsgroups: | comp.lang.c |
Bartc wrote:
> "CBFalconer" <cbfalconer@xxxxxxxxx> wrote in message
>
... snip ...
>
>> if ((cmdcode < 1000) || (cmdcode > 2999)) misccmds();
>> else if (cmdcode < 2000) filecmds();
>> else if (cmdcode < 2500) editcmds();
>> else viewcmds();
>>
>> which I consider readable and legitimate.
>
> The code below is virtually identical to my fragment above and
> compiles and runs with gcc.
>
... snip ...
>
> switch (cmdcode)
> {case 1000 ... 1999: filecmds(cmdcode); break;
> case 2000 ... 2499: editcmds(cmdcode); break;
> case 2500 ... 2999: viewcmds(cmdcode); break;
> default: misccmds(cmdcode);
> };
It is still not acceptable to standard C. In addition, if you
examine the generated code, you may find that is has been converted
to my code in the first place, or that it is generating a 2000
entry transfer table (may depend on optimization), which is not
exactly optimum code. It doesn't hurt to have a rough idea of what
the compiler generates.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from www.teranews.com">http://www.teranews.com
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: ?: as an lvalue, Ben Bacarisse |
|---|---|
| Next by Date: | Re: ?: as an lvalue, Rahul |
| Previous by Thread: | Re: case labels, Bartc |
| Next by Thread: | Re: case labels, Ben Pfaff |
| Indexes: | [Date] [Thread] [Top] [All Lists] |