summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--md/notes/undefined_c/titles.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/md/notes/undefined_c/titles.md b/md/notes/undefined_c/titles.md
index 92b35ab..0108449 100644
--- a/md/notes/undefined_c/titles.md
+++ b/md/notes/undefined_c/titles.md
@@ -282,7 +282,41 @@ ulimit -s 16384
### Macro
+There is many things useful as macros. There is many tricks in macros to emit
+useful parts of code.
+Define values, as its enum.
+```c
+#define VAL_0 0
+#define VAL_1 1
+#define VAL_LAST VAL_1
+```
+
+Multiline macro
+```c
+#define INC_FUN(TYPE) TYPE inc_##TYPE(a TYPE){\
+ TYPE c=1\
+ return a + c\
+}
+
+INC_FUN(int)
+INC_FUN(char)
+INC_FUN(double)
+INC_FUN(notype)
+```
+
+to check code expansion of macro run
+
+```
+gcc -E <SOURCE_FILE>
+```
+
+
+
+http://main.lv/writeup/c_macro_tricks.md
+
+
+https://jadlevesque.github.io/PPMP-Iceberg/
### Signed/Unsigned
### Pointers