ADT
ast-experimental
pthread-emulation
qualifiedEnum
Last change
on this file since ac1aba4b was fc134a48, checked in by JiadaL <j82liang@…>, 3 years ago |
Implement the struct enum
|
-
Property mode
set to
100644
|
File size:
558 bytes
|
Rev | Line | |
---|
[fc134a48] | 1 | #include <stdio.h>
|
---|
| 2 |
|
---|
| 3 | struct Point {
|
---|
| 4 | int x;
|
---|
| 5 | char y;
|
---|
| 6 | };
|
---|
| 7 |
|
---|
| 8 | enum(Point) PointEnum {
|
---|
| 9 | first={
|
---|
| 10 | 100,
|
---|
| 11 | 'c'
|
---|
| 12 | },
|
---|
| 13 | second={
|
---|
| 14 | 200,
|
---|
| 15 | 'a'
|
---|
| 16 | }
|
---|
| 17 | };
|
---|
| 18 |
|
---|
| 19 | // The only valid usage
|
---|
| 20 | struct Point apple = first;
|
---|
| 21 | // Failed due to Qualified name is currently unimplemented.
|
---|
| 22 | // struct Point banana = PointEnum.first;
|
---|
| 23 |
|
---|
| 24 | int main() {
|
---|
| 25 | printf("%d %c\n", apple.x, apple.y);
|
---|
| 26 | // Failed; enumInstType is now not a real type and not instantiated.
|
---|
| 27 | // Not sure if we want that
|
---|
| 28 | // printf("%d %c\n", second.x, second.y);
|
---|
| 29 | return 0;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.