Are enums safe to use in portable code?

Stephen Clamage steve at taumet.com
Fri Feb 1 03:50:29 AEST 1991


bliss at sp64.csrd.uiuc.edu (Brian Bliss) writes:

> The alliant fx C compiler (for an fx1 or fx8, not fx2800), supports
> them, but gives errors when you try to compare two enum constants.

Enums are well-defined and safe in standard (ANSI/ISO) C.  However,
enums were introduced helter-skelter by different vendors years
earlier, with no written standard to refer to.  Apart from compiler
bugs, different implementors had different ideas of how enums should
work.  At least one vendor did not allow an enum to index an array,
for example.  So if you need to port code among lots of pre-standard
or non-standard compilers, it is probably best not to use enums.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list