| 1 |
typedef enum { POSITION_ASIS, POSITION_UNSPECIFIED } unit_position; |
| 2 |
|
| 3 |
typedef enum { STATUS_UNKNOWN, STATUS_UNSPECIFIED } unit_status; |
| 4 |
|
| 5 |
typedef struct |
| 6 |
{ |
| 7 |
unit_position position; |
| 8 |
unit_status status; |
| 9 |
} unit_flags; |
| 10 |
|
| 11 |
extern void abort (void); |
| 12 |
|
| 13 |
void |
| 14 |
new_unit (unit_flags * flags) |
| 15 |
{ |
| 16 |
if (flags->status == STATUS_UNSPECIFIED) |
| 17 |
flags->status = STATUS_UNKNOWN; |
| 18 |
|
| 19 |
if (flags->position == POSITION_UNSPECIFIED) |
| 20 |
flags->position = POSITION_ASIS; |
| 21 |
|
| 22 |
switch (flags->status) |
| 23 |
{ |
| 24 |
case STATUS_UNKNOWN: |
| 25 |
break; |
| 26 |
|
| 27 |
default: |
| 28 |
abort (); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
int main() |
| 33 |
{ |
| 34 |
unit_flags f; |
| 35 |
f.status = STATUS_UNSPECIFIED; |
| 36 |
new_unit (&f); |
| 37 |
return 0; |
| 38 |
} |