[Swan-dev] explicitly assigned enum values

D. Hugh Redelmeier hugh at mimosa.com
Tue Jul 15 23:21:58 EEST 2014


One of the great things about enums (as opposed to #defines) is that the 
compiler will automatically assign values.

Sometimes you don't want to leave the value assignment to the compiler.  A 
good example would be numbers assigned by IANA.

Some of our enums in include/pluto_constants.h are explicitly assigned for 
no obvious reason.  I think we should undo this (or document why not).

    kernel_interface
    keyword_remotepeertype
    keyword_xauthby

And another thing about enums.  It might be good, all other things
being equal, to define a throw away first memver.  This will be assigned
the value 0.  That way 0 won't be a legitimate value, and that is the
most common value that would come up if a variable were not
initialized.  A way to catch more errors.


More information about the Swan-dev mailing list