ရိုးရိုးလေး ရှင်းပြမယ်
ရိုးရိုးလေး ရှင်းရရင်
Enum (enumeration) ဆိုတာ နာမည်ပေးထားတဲ့ ရွေးချယ်စရာ အစုတစ်ခုကို စာရင်းပြုစုထားတဲ့ type ပါ။ 0 က low၊ 1 က medium၊ 2 က high လို့ မှတ်ထားမယ့်အစား enum Level { LOW, MEDIUM, HIGH }; လို့ ရေးပြီး နာမည်တွေကို သုံးပါတယ်။ Computer က ကိန်းပြည့် သေးသေးလေးတွေကိုပဲ သိမ်းနေဆဲပါ — နာမည်တွေက code ကို ဖတ်ပြီး ထိန်းသိမ်းမယ့် လူတွေအတွက်ပါ။
စာရင်းတိုတစ်ခုထဲက တစ်ခု ဖြစ်တဲ့ အရာတိုင်းနဲ့ enum က ကိုက်ပါတယ် — order တစ်ခုရဲ့ status၊ game character မျက်နှာမူတဲ့ ဘက်၊ ရက်သတ္တပတ်ထဲက နေ့၊ menu ရွေးချယ်မှု။ enum OrderStatus type ရှိတဲ့ variable ကို မြင်တာနဲ့ ဘယ် value တွေ အဓိပ္ပာယ်ရှိလဲ ချက်ချင်း သိပါတယ်။
Problem → Why → Solution
ပြဿနာ: magic number တွေက ဘာကိုမှ မပြော
ဂဏန်းအလွတ်တွေနဲ့ ရေးထားတဲ့ order-processing code က ရေးတဲ့နေ့မှာ အလုပ်လုပ်ပါတယ်။ ခြောက်လကြာတော့ status 2 က paid လား shipped လား ဘယ်သူမှ မမှတ်မိတော့ဘဲ status အသစ်တစ်ခုက မတော်တဆ 2 ကို ရသွားတယ်၊ status == 22 လို စာလုံးပေါင်းအမှားကလည်း ဘာမှ မပြောဘဲ compile ဖြစ်ပါတယ်။ အောက်က code က မှန်ပါတယ်၊ ဒါပေမယ့် ဖတ်ရုံနဲ့ အဲဒါကို မသိနိုင်ပါဘူး — 9 ကို ပို့ရင်လည်း ဘာမှ print မထုတ်ပါဘူး။
#include <stdio.h>
void describe(int status) {
if (status == 1) {
printf("waiting for payment\n");
} else if (status == 2) {
printf("ready to ship\n");
} else if (status == 3) {
printf("on its way\n");
}
/* what about 9? nobody remembers that it means cancelled */
}
int main(void) {
describe(2);
describe(9); /* prints nothing at all */
return 0;
}ဂဏန်းအလွတ်တွေက ဘာကြောင့် အန္တရာယ်ရှိတာလဲ
ဂဏန်းအလွတ်တွေမှာ အဓိပ္ပာယ် မပါလို့ 1, 2, 3 က ဘာကို ကိုယ်စားပြုလဲဆိုတဲ့ အသိက လူတွေရဲ့ ခေါင်းထဲမှာ ဒါမှမဟုတ် ခေတ်နောက်ကျသွားတတ်တဲ့ comment တွေထဲမှာပဲ ရှိပါတယ်။ int တိုင်းက တခြား int တွေလို တရားဝင်လို့ compiler က မကူညီနိုင်ပါဘူး။ Enum က value တစ်ခုစီကို နာမည်နဲ့ type ပေးပါတယ် — code က business rule လို ဖတ်ရလာပြီး enum ပေါ်က switch မှာ မေ့ထားတဲ့ case တွေကို GCC က ထောက်ပြနိုင်ကာ value တစ်ခု ပြောင်းဖို့ နေရာ တစ်ခုတည်းမှာပဲ ပြင်ရပါတယ်။
Core concept: နာမည်ပေးထားတဲ့ integer constant များ
enum Level { LOW, MEDIUM, HIGH }; က အရာနှစ်ခုကို တစ်ပြိုင်တည်း ကြေညာပါတယ် — type အသစ် enum Level နဲ့ enumeration constant သုံးခုပါ။ ကိုယ်တိုင် မသတ်မှတ်ရင် ပထမ constant က 0 ဖြစ်ပြီး နောက်တစ်ခုစီက ရှေ့က value ထက် တစ် ပိုလို့ LOW က 0၊ MEDIUM က 1၊ HIGH က 2 ပါ။ ကြိုက်တဲ့ value ကို ရှင်းရှင်း သတ်မှတ်နိုင်ပါတယ် — enum Color { RED, GREEN = 5, BLUE }; မှာ နောက်ဆုံး explicit value ကနေ ဆက်ရေတွက်လို့ BLUE က 6 ဖြစ်ပါတယ်။ Constant နှစ်ခုက value တူတူ ရှိတာတောင် ဖြစ်နိုင်ပါတယ်။
C17 မှာ enumeration constant တိုင်းရဲ့ type က int ဖြစ်လို့ integer သုံးလို့ရတဲ့ နေရာတိုင်းမှာ သုံးလို့ရပါတယ် — array index၊ arithmetic၊ switch case label။ Enum type ကိုယ်တိုင်ကတော့ compiler ရွေးတဲ့ integer type တစ်ခုနဲ့ compatible ဖြစ်ပါတယ် (GCC က constant တစ်ခုမှ အနှုတ် မဟုတ်ရင် unsigned int၊ မဟုတ်ရင် int ကို သုံးပါတယ်)၊ x86-64 ပေါ်က GCC မှာ sizeof(enum Level) က 4 ပါ။ အဲဒီ အရွယ်အစားကို file ဒါမှမဟုတ် network message တွေမှာ မမှီခိုပါနဲ့၊ အရွယ်အစား ရှင်းရှင်းလင်းလင်း သတ်မှတ်ထားတဲ့ integer ကို သိမ်းပါ။
C က enum variable ထဲမှာ တခြား ဂဏန်းတွေ ရှိတာကို မတားပါဘူး။ enum Level l = 42; က -Wall -Wextra နဲ့တောင် တိတ်တိတ်လေး compile ဖြစ်ပြီး file ဒါမှမဟုတ် user ဆီကနေ ဖတ်တဲ့ value က ဘာမဆို ဖြစ်နိုင်ပါတယ်။ ဒါကြောင့် enum ကို program ရဲ့ အစွန်းတွေမှာ ကိုယ်တိုင် စစ်ရမယ့် ကတိတစ်ခုလို့ သဘောထားပါ — ဝင်လာတဲ့ integer တွေကို validate လုပ်တဲ့ function နဲ့ ပြောင်းပြီး switch တိုင်းမှာ မသိတဲ့ value တွေကို ကိုင်တွယ်မယ့် လမ်းကြောင်း ထားပါ။
Enumeration constant တွေက variable နဲ့ function တွေနဲ့ scope တစ်ခုတည်းကို မျှသုံးလို့ file တစ်ခုထဲက enum နှစ်ခုမှာ NONE ဆိုတဲ့ constant နှစ်ခု မရှိနိုင်ပါဘူး၊ GCC က redeclaration of enumerator 'NONE' လို့ report လုပ်ပါတယ်။ C code တွေက ORDER_PENDING၊ LEVEL_HIGH လို constant တွေကို type နာမည်နဲ့ prefix တပ်ရတာ အဲဒါကြောင့်ပါ။ နောက်ဆုံးမှာ LEVEL_COUNT constant ထည့်တာက အသုံးများတဲ့ နည်းလမ်းတစ်ခုပါ — တကယ့် value အရေအတွက်နဲ့ ညီလို့ နာမည် table ရဲ့ အရွယ်အစားအဖြစ် သုံးနိုင်ပါတယ်။
- ရွေးစရာ စာရင်း: enum T { A, B, C }
- နာမည်တွေ int ဖြစ်: A=0, B=1, C=2
- Code က ဂဏန်း မဟုတ်ဘဲ နာမည် နှိုင်းယှဉ်
- အပြင်ကလာတဲ့ ဂဏန်းကို validate လုပ်
Enum က ဘယ် value တွေ အဓိပ္ပာယ်ရှိလဲ မှတ်တမ်းတင်ပေးပေမယ့် တခြား integer တွေ ဝင်လာတာကို မတားပါဘူး။
အထွေထွေ ပုံစံ
enum Name {
NAME_FIRST, /* 0 */
NAME_SECOND, /* 1 */
NAME_LATER = 10, /* explicit value */
NAME_NEXT /* 11 */
};
enum Name value = NAME_SECOND;
switch (value) {
case NAME_FIRST: /* ... */ break;
default: /* unknown or unhandled values */ break;
}Constant တွေက 0 ကနေ စပြီး တစ်ခုစီ တစ် တိုးပါတယ်၊ = value နဲ့ သတ်မှတ်ရင် အဲဒီကနေ ဆက်ရေတွက်ပါတယ်။ Enum variable ကို ကြေညာပြီး switch နဲ့ constant တစ်ခုချင်းအလိုက် ကိုင်တွယ်ပါတယ်။
Example: level တစ်ခုကို နာမည်နဲ့ စစ်ခြင်း
ဒီ program တိုလေးက အသုံးဝင်တဲ့ အသေးဆုံး enum ပါ — နာမည်ပေးထားတဲ့ level သုံးခုပါတဲ့ type တစ်ခုနဲ့ နှိုင်းယှဉ်ချက် တစ်ခု။ သူ့တန်ဖိုးက ဖတ်သူ မြင်ရတဲ့ အရာမှာ ရှိပါတယ် — current == MEDIUM က ကိုယ့်ဘာသာ ရှင်းပြပြီး current == 1 ဆိုရင် comment လိုပါမယ်။ အောက်က deeper section တွေက ဒါကို တကယ့် code သုံးတဲ့ pattern တွေဆီ ချဲ့ပါတယ် — switch၊ name table နဲ့ COUNT constant။
#include <stdio.h>
enum Level {
LOW,
MEDIUM,
HIGH
};
int main() {
enum Level current = MEDIUM;
if (current == MEDIUM) {
printf("Current level is medium.");
}
return 0;
}Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်
- Lines 3-7
enum Level {Type enum Level နဲ့ constant သုံးခု LOW = 0, MEDIUM = 1, HIGH = 2 ကို ကြေညာပါတယ်။ Constant နာမည်တွေက file တစ်ခုလုံးမှာ မြင်ရလို့ project ကြီးတွေမှာ LEVEL_LOW လို prefix တပ်တာ ပိုကောင်းပါတယ်။
- Line 9
int main() {C17 မှာ () ဆိုတာ parameter တွေကို မဖော်ပြထားတာပါ၊ parameter မရှိဘူးလို့ အတိအကျ ပြောချင်ရင် int main(void) လို့ ရေးတာ ပိုတိကျပါတယ် (C23 မှာတော့ နှစ်ခု အဓိပ္ပာယ်တူပါပြီ)။
- Line 10
enum Level current = MEDIUM;enum Level type variable တစ်ခုကို MEDIUM နဲ့ initialize လုပ်ပါတယ်။ Memory ထဲမှာ 1 ကိုပဲ သိမ်းပေမယ့် code ကို ဖတ်တဲ့သူက level ကို မြင်ပါတယ်။
- Line 12
if (current == MEDIUM) {နှိုင်းယှဉ်ချက်က လိုအပ်ချက်လို ဖတ်ရပါတယ်။ Compiler အတွက်တော့ 1 နဲ့ နှိုင်းယှဉ်တာနဲ့ အတူတူပဲ — enum က runtime cost မရှိပါဘူး။
Current level is medium.switch, -Wswitch နဲ့ မသိတဲ့ value များ
Enum ပေါ်က switch တစ်ခုမှာ default မပါဘဲ constant တစ်ခု လွတ်နေရင် -Wall ထဲက -Wswitch က enumeration value 'HIGH' not handled in switch လို့ သတိပေးပါတယ်။ ဒီ warning က အဖိုးတန်လို့ အသုံးများတဲ့ style တစ်ခု ပေါ်လာပါတယ် — enum ကို စာသားပြောင်းတဲ့ function ထဲမှာ constant အားလုံးကို စာရင်းပြုစုပြီး default ကို ချန်ထားကာ enum အပြင်ဘက်က value တွေအတွက် switch နောက်မှာ fallback တစ်ခု return ပြန်တာပါ။
#include <stdio.h>
enum Level { LEVEL_LOW, LEVEL_MEDIUM, LEVEL_HIGH };
const char *level_name(enum Level level) {
switch (level) { /* no default: -Wswitch reports missing cases */
case LEVEL_LOW: return "low";
case LEVEL_MEDIUM: return "medium";
case LEVEL_HIGH: return "high";
}
return "unknown"; /* values outside the enum end up here */
}
int main(void) {
for (int raw = 0; raw <= 3; raw++) {
printf("%d -> %s\n", raw, level_name((enum Level)raw));
}
return 0;
}Output က 0 -> low၊ 1 -> medium၊ 2 -> high၊ 3 -> unknown ပါ။ နောင်မှာ LEVEL_CRITICAL ထပ်ထည့်ရင် compiler က level_name() ကို ချက်ချင်း ထောက်ပြပါမယ်။ default: ထည့်ထားခဲ့ရင်တော့ အဲဒီ warning ပျောက်သွားပြီး constant အသစ်က "unknown" ကို တိတ်တိတ်လေး ပြန်ပေးပါမယ်။
COUNT constant နဲ့ enum ကို index အဖြစ် သုံးခြင်း
Enum constant တွေက 0 ကနေ ဆက်တိုက် ဖြစ်တဲ့အခါ array index အဖြစ် သုံးလို့ရပါတယ်။ နောက်ဆုံးက DIR_COUNT က array အရွယ်အစားနဲ့ loop တွေကို enum နဲ့ အမြဲ ကိုက်ညီအောင် ထိန်းပေးပါတယ်။
#include <stdio.h>
enum Direction { DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST, DIR_COUNT };
static const char *const DIRECTION_NAMES[DIR_COUNT] = {
"north", "east", "south", "west"
};
int main(void) {
enum Direction moves[] = {DIR_NORTH, DIR_EAST, DIR_NORTH, DIR_WEST, DIR_NORTH};
int counts[DIR_COUNT] = {0};
for (size_t i = 0; i < sizeof moves / sizeof moves[0]; i++) {
counts[moves[i]]++;
}
for (int d = 0; d < DIR_COUNT; d++) {
printf("%-5s: %d\n", DIRECTION_NAMES[d], counts[d]);
}
return 0;
}ဒီ program က north: 3၊ east: 1၊ south: 0၊ west: 1 ကို print ထုတ်ပါတယ်။ Direction အသစ်ကို DIR_COUNT ရဲ့ ရှေ့မှာ ထည့်သရွေ့ array အရွယ်အစားနဲ့ loop တွေ မှန်နေဆဲပါ။ ဒီမှာ enum နဲ့ index လုပ်တာ ဘေးကင်းတာက moves ထဲက value တိုင်း enum ကိုယ်တိုင်ကနေ လာလို့ပါ၊ အပြင်ကလာတဲ့ ဂဏန်းဆိုရင်တော့ အရင် range စစ်ရပါမယ်။
လက်တွေ့ project တွေမှာ
Real project တွေမှာ ဘယ်လို သုံးလဲ
C API တွေမှာ enum တွေ နေရာတိုင်း ရှိပါတယ်။ C standard library ကိုယ်တိုင်က constant အများစုအတွက် ရိုးရိုး macro တွေ သုံးပေမယ့် library ကြီးတွေက enum ကို အားကိုးကြပါတယ် — Vulkan ရဲ့ VkResult က success နဲ့ error code တွေကို စာရင်းပြုစုပြီး SDL က key code နဲ့ event type တွေအတွက် enum သုံးပါတယ်။ Embedded project တိုင်းနီးပါးက IDLE, CONNECTING, CONNECTED, ERROR လို state machine ရဲ့ state တွေကို switch နဲ့ မောင်းတဲ့ enum အဖြစ် ဖော်ပြပါတယ်။
Enum value တွေ boundary တစ်ခုကို ဖြတ်တဲ့အခါ real project တွေက သူတို့ကို တည်ငြိမ်အောင် ချုပ်ထားပါတယ်။ Database ထဲ သိမ်းတဲ့ ဒါမှမဟုတ် network ကနေ ပို့တဲ့ value တွေကို explicit number (ORDER_PAID = 2) ပေးထားလို့ declaration ကို ပြန်စီတာက သိမ်းပြီးသား data ကို တိတ်တိတ်လေး မပြောင်းနိုင်ပါဘူး၊ parse function က ဝင်လာတဲ့ integer ဒါမှမဟုတ် string တွေကို enum ပြောင်းရင်း မသိတာမှန်သမျှကို ငြင်းပါတယ်။ ကိုက်ညီတဲ့ to-string function က status=2 အစား status=PAID လို log message တွေ ထုတ်ပေးလို့ production log တွေ ဖတ်ရ လွယ်ပါတယ်။
အမှားများ
အဖြစ်များတဲ့ အမှားတွေ
1. Enum variable က declared value တွေပဲ ကိုင်နိုင်တယ် ထင်တာ
enum Level l = 42; က warning မပါဘဲ compile ဖြစ်ပြီး input ကနေ ဖတ်တဲ့ ဂဏန်းကို cast လုပ်တာလည်း အတူတူပါပဲ။ အဲဒီ value နဲ့ name table ကို index လုပ်တဲ့ code က array အပြင်ဘက်ကို ဖတ်မိပါတယ်။ Integer တွေ program ထဲ ဝင်လာတဲ့နေရာမှာ validate လုပ်ပြီး switch တိုင်းနောက်မှာ fallback ထားပါ။
2. ဂဏန်းတွေ သိမ်းထားတဲ့ enum ထဲ constant ပြန်စီတာ၊ ကြားထည့်တာ
ဒီနေ့ ORDER_PAID က implicit 1 ဖြစ်ပြီး တစ်ယောက်ယောက်က သူ့ရှေ့မှာ ORDER_REVIEW ထည့်လိုက်ရင် file ထဲမှာ သိမ်းပြီးသား PAID order တိုင်းကို REVIEW အဖြစ် ပြန်ဖတ်ပါတယ်။ Program အပြင်ကို ဂဏန်းတွေ ထွက်သွားတဲ့ enum မှန်သမျှကို explicit value ပေးပြီး constant အသစ်တွေကို နောက်ဆုံးမှာပဲ ထပ်ထည့်ပါ။
3. Enum နှစ်ခုမှာ constant နာမည် တူတူ သုံးတာ
File တစ်ခုထဲမှာ enum Status { NONE, ACTIVE }; နဲ့ enum Filter { NONE, ALL }; ရှိရင် redeclaration of enumerator 'NONE' နဲ့ fail ဖြစ်ပါတယ်။ Constant တွေကို သူတို့ type နဲ့ prefix တပ်ပါ (STATUS_NONE, FILTER_NONE)။
4. လွတ်နေတဲ့ case တွေကို ဖုံးထားတဲ့ default ထည့်တာ
default label က -Wswitch ကို ငြိမ်သွားစေလို့ အသစ်ထည့်တဲ့ constant က ဘာ warning မှ မပါဘဲ generic branch ထဲ ကျသွားပါတယ်။ Constant တိုင်းကို ဖုံးရမယ့် switch တွေမှာ အားလုံးကို စာရင်းပြုစုပြီး range ပြင်ပ value တွေကို switch နောက်မှာ ကိုင်တွယ်ပါ။
Best Practices
အကောင်းဆုံး အလေ့အကျင့်များ
- Constant တိုင်းကို enum နာမည်နဲ့ capital letter prefix တပ်ပါ၊ နာမည်တိုက်တာ ရှောင်ပြီး type ကို ရှင်းစေပါတယ်။
- သိမ်းတဲ့ ဒါမှမဟုတ် ပို့တဲ့ enum တွေမှာ explicit value သုံးပြီး ဘယ်တော့မှ နံပါတ် ပြန်မတပ်ပါနဲ့။
- အရေးကြီးတဲ့ enum တွေကို validate လုပ်တဲ့ parse function နဲ့ to-string function တို့နဲ့ တွဲထားပါ။
Mini challenge
Mini challenge: order status code များ
Order file ကနေ ဖတ်ထားတဲ့ code တွေကို enum အဖြစ် ဘေးကင်းကင်း ပြောင်းပြီး နာမည်နဲ့ print ထုတ်ပါ။
- ORDER_PENDING = 1, ORDER_PAID = 2, ORDER_SHIPPED = 3, ORDER_CANCELLED = 9 explicit value တွေပါတဲ့ enum OrderStatus ရေးရမယ်
- const char *status_name(enum OrderStatus s) က constant တိုင်းပေါ် switch သုံးပြီး capital letter နာမည်ကို ပြန်ပေးရမယ်
- int parse_status(int raw, enum OrderStatus *out) က သိတဲ့ code ဆိုရင် status ကို သိမ်းပြီး 1 ပြန်ရမယ်၊ မဟုတ်ရင် 0 ပြန်ရမယ်
- {1, 3, 7, 9} code တွေကို process လုပ်ပြီး နာမည် ဒါမှမဟုတ် invalid status code ကို print ထုတ်ရမယ်
#include <stdio.h>
enum OrderStatus {
// TODO: PENDING = 1, PAID = 2, SHIPPED = 3, CANCELLED = 9, with an ORDER_ prefix
};
const char *status_name(enum OrderStatus status) {
// TODO: switch over every constant; return "UNKNOWN" after the switch
}
int parse_status(int raw, enum OrderStatus *out) {
// TODO: accept only the four known codes, store through out, return 1
// TODO: return 0 for anything else
}
int main(void) {
int codes_from_file[] = {1, 3, 7, 9};
// TODO: parse each code and print "1 -> PENDING" or "7 -> invalid status code"
return 0;
}ရလဒ်: Output က ဒီလို ဖြစ်ရပါမယ်: 1 -> PENDING 3 -> SHIPPED 7 -> invalid status code 9 -> CANCELLED
အရိပ်အမြွက် ကြည့်ရန်
parse_status ထဲမှာ switch (raw) ကို သုံးပြီး case ORDER_PENDING: case ORDER_PAID: ... လို case label လေးခုကို ဆက်တိုက် ရေးကာ *out = (enum OrderStatus)raw; return 1; လုပ်နိုင်ပါတယ်။ default: က 0 ပြန်ပါတယ်။ status_name မှာတော့ default မထည့်ဘဲ switch နောက်မှာ "UNKNOWN" ကို return ပြန်ပါ။
အဖြေ ကြည့်ရန်
#include <stdio.h>
enum OrderStatus {
ORDER_PENDING = 1,
ORDER_PAID = 2,
ORDER_SHIPPED = 3,
ORDER_CANCELLED = 9
};
const char *status_name(enum OrderStatus status) {
switch (status) {
case ORDER_PENDING: return "PENDING";
case ORDER_PAID: return "PAID";
case ORDER_SHIPPED: return "SHIPPED";
case ORDER_CANCELLED: return "CANCELLED";
}
return "UNKNOWN";
}
/* Returns 1 and stores the status when raw is a known code, else 0. */
int parse_status(int raw, enum OrderStatus *out) {
switch (raw) {
case ORDER_PENDING:
case ORDER_PAID:
case ORDER_SHIPPED:
case ORDER_CANCELLED:
*out = (enum OrderStatus)raw;
return 1;
default:
return 0;
}
}
int main(void) {
int codes_from_file[] = {1, 3, 7, 9};
for (int n = 0; n < 4; n++) {
enum OrderStatus status;
if (parse_status(codes_from_file[n], &status)) {
printf("%d -> %s\n", codes_from_file[n], status_name(status));
} else {
printf("%d -> invalid status code\n", codes_from_file[n]);
}
}
return 0;
}Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
မှတ်ထားရမယ့် အချက်များ
- Enum က type တစ်ခုနဲ့ value မသတ်မှတ်ရင် 0 ကနေ ရေတွက်တဲ့ နာမည်ပေးထားတဲ့ integer constant တွေကို ကြေညာပါတယ်။
- C17 မှာ enumeration constant တွေက int ဖြစ်ပြီး enum ကိုယ်တိုင်ရဲ့ အရွယ်အစားကို compiler က ရွေးလို့ raw အတိုင်း မသိမ်းပါနဲ့။
- C က enum variable ထဲ integer မည်သည့်ဟာကိုမဆို ခွင့်ပြုလို့ အပြင်ကလာတဲ့ value တွေကို validate လုပ်ပြီး မသိတာတွေကို ကိုင်တွယ်ပါ။
- Constant တွေကို type နာမည်နဲ့ prefix တပ်ပြီး သိမ်းတဲ့ ဒါမှမဟုတ် ပို့တဲ့ enum တွေကို explicit value ပေးပါ။
GNU C compiler diagnostics — GNU Project