enum implementation

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Jul 27 01:27:57 AEST 1989


In article <396 at opusys.UUCP> rlkd at opusys.UUCP (R.L.K.Dattatri) writes:
>Recently, while using two different compilers I ran into a problem ...

That is always a danger.  Mixing C implementations on a single system
is generally unsafe.  There are many implementation-dependent aspects
of C, and if two different compilers embody two different choices they
may produce object modules that are incompatible.

>Question: What is the standard (ANSI) type of an 'enum' constant?
>	  The ANSI-C standard just says ...

You just answered your own question.

>Some compilers determine the type based on the number of constants 
>in the 'enum' type. Some compilers provide an option to set the
>enum constants to 'int's.
>So what is the correct way of implementing 'enum'.

Both those alternatives are valid, as are some other possibilities.
What is invalid is for "enum" to be treated as a type incompatible
with integer operations.  At least one release of PCC did that, and
drove a lot of programmers up the wall.



More information about the Comp.lang.c mailing list