Re: Question about "enums"



Harald van Dijk wrote:
Ian Collins wrote:

venkatesh wrote:

u can make use of okloop whereever u want "1"
if if is not that please correct me


What are you replying to? Please quote the context.

Assuming you are refereing to:

enum loop { NO, YES};
enum loop okloop=YES;

You would use loop whenever you wanted YES. Use an enum for what it is,
if you wanted a synonym for 1, use a const (unsigned) int.


A const int can't be used in constant expressions.

Another oversight that should have been fixed.

I'll admit declaring
okloop as int in that example is probably not a good idea, but do you
have a problem with unnamed enums used to define constants too?

No, it's the only tidy workaround for the previous oversight.

--
Ian Collins.
.



Relevant Pages

  • [git patches] net driver updates for .27
    ... static int lance_open (struct net_device *dev) ... enum mac8390_type type); ... unsigned int fifo_count, timeout, reg; ...
    (Linux-Kernel)
  • Re: why still use C?
    ... I was talking about the malloc expression, ... >>the assignment expression. ... >>enum parameter is not an error in C, but in my coding style it's a mistake). ... I took it you meant "int where an enum" is expected, ...
    (comp.lang.c)
  • Re: enums aint no good
    ... C's low level spirit. ... feels like typical ultra high level scripting language ... The compiler could not optimize an enum if it wanted to, ... int or unsigned int) are faster than operations on bytes. ...
    (comp.lang.c)
  • [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1
    ... Constify struct dma_map_ops with some exceptions. ... extern void set_iommu_machvec; ... static inline int dma_supported ... enum dma_data_direction dir, ...
    (Linux-Kernel)
  • Re: Behaviour of enumerated types
    ... >> keys to other ordered info? ... If you want sequence numbers, ... the enum object itself can be used directly as an iterable. ... >> To me the int correspondence is as expectable and natural as ...
    (comp.lang.python)