Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: enum implementation Keywords: enum, types, char/int Message-ID: <10612@smoke.BRL.MIL> Date: 26 Jul 89 15:27:57 GMT References: <396@opusys.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 22 In article <396@opusys.UUCP> rlkd@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.