enums - Ada enumerations with duplicate values -
i'm trying have device register enumeration. reading register has 2 values -> 0 means done, 1 means pending. likewise, writing register has 2 values -> 0 has no action , 1 reset. so, wrote following code
type soft_reset (done, pending, no_action, reset); soft_reset use (done => 0, pending => 1, no_action => 0, reset => 1);
but throws error
gcc-4.6 -c -g -gnatg -ggdb -i- -gnata /home/sid/tmp/device.adb device.ads:93:20: enumeration value "no_action" not ordered gnatmake: "/home/sid/tmp/device.adb" compilation error
is possible enumeration have duplicate values?
i don't think so. think more elegant create 2 enumerated types indicating 1 corresponds possible readable values of register , other 1 corresponds writable values.
something like:
type register_status (done, pending) -- values can read type soft_reset (no_action, reset) -- values can written
gneuromante's post @ bottom direct answer question.
Comments
Post a Comment