aboutsummaryrefslogtreecommitdiff
path: root/examples/table.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/table.c')
-rw-r--r--examples/table.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/table.c b/examples/table.c
new file mode 100644
index 0000000..63edb16
--- /dev/null
+++ b/examples/table.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+@table(name, str) MyEnumTable
+{
+ { A "A" }
+ { B "Beau Gosse" }
+ { C "C" }
+}
+
+typedef enum {
+@expand(MyEnumTable a)
+` MyEnum_$(a.name),`
+ MyEnum_Count
+} MyEnum;
+
+char *StringTable[MyEnum_Count] = {
+@expand(MyEnumTable a)
+` $(a.str),`
+};
+
+int
+main(int Argc, char *Args[])
+{
+ printf("@: %s\n", StringTable[MyEnum_B]);
+
+ return 0;
+}