source: tests/enum_tests/stringEnum.cfa @ 3d618a0

Last change on this file since 3d618a0 was eb7586e, checked in by JiadaL <j82liang@…>, 7 months ago
  1. Change return value of typed Enum in null context: they now return the position. Therefore, printf with enumeration value will no longer be supported. 2. sout now will return the enumeration value. So sout | enumValue will print what we expect. 3. Provide enum.hfa, which contains traits that related to enum. 4. Implement functions declare in enum.hfa for enum types, so enum type fulfill the traits. Known defeat: error if we use the enum traits on enum types. They work but c compiler gives an warning
  • Property mode set to 100644
File size: 220 bytes
RevLine 
[eb7586e]1#include <fstream.hfa>
[d8e2a09]2#include <stdio.h>
3
4enum(char *) IntEnum {
5    zero="zero",
6    one="one"
7};
8
9int main() {
[eb7586e]10    sout | "zero: "| zero | ", one: " | one;
11    printf("zero: %d, one: %d\n", zero, one);
[d8e2a09]12    return 0;
13}
Note: See TracBrowser for help on using the repository browser.