Re: Question about "enums"




Ian Collins wrote:


Assigning any other value to a loop is undefined. Unfortunately C
compilers don't regard this as an error, which renders enums little more
than symbolic constants.


Is this what you mean?

enum months{Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec};
enum months mymonths=14; / * Should really raise an outofbounds
exception ? */

printf("I have chosen month %d", mymonths); /* prints 14 */

.



Relevant Pages

  • Re: MATMUL slower than expected
    ... a couple of the compilers are faster running explicit loops than using MATMUL. ... double loop with dot_product: 11.52825 ...
    (comp.lang.fortran)
  • Re: Duffs Device
    ... I'd disagree a little on the above assessment that even in C unless you were looking at a very low-level case similar to what Glen was talking about would the optimizer not likely make such improvements as were appropriate for the specific hardware platform/compiler implementation if one simply wrote the "straightahead" loop. ... If, of course, there's a lot of indirection and all inside, that could limit optimization but for the simple case don't think it would help much for most modern compilers. ...
    (comp.lang.fortran)
  • Re: Likely/Unlikely and standards
    ... Some will say this subject should be left entirely to forums dedicated to particular compilers or platforms, but there are a few generalizations. ... Default optimization for conditional branch not taken is a de facto standard. ... There should be no performance penalty for the use of a break, except that it is preferable to use an ifblock rather than break, in the case where the last part of a loop body is to be skipped on the last loop iteration. ... I have waged a several year campaign against compilers requiring break to be placed in an else block to enable optimization. ...
    (comp.lang.c)
  • Re: Likely/Unlikely and standards
    ... general" case e.g remain standard compliant and platform independant? ... to particular compilers or platforms, but there are a few generalizations. ... there is a conditional loop exit, the branch which leads to continued ... more compact code. ...
    (comp.lang.c)
  • Re: Is this code computationally economical?
    ... xsum = xsum+fac*xx ... echo Set colItems = objWMIService.ExecQuery("Select * from ... At first glance, I wondered why you didn't use *.5 in your signversion, in order to give compilers a better chance when sane options are in use. ... The compilers mentioned leave room for improved optimization by loop fusion, which should improve performance of f90 code. ...
    (comp.lang.fortran)