diff options
author | FreeArtMan <dos21h@gmail.com> | 2022-08-09 11:15:08 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2022-08-09 11:15:08 +0100 |
commit | 8d2aaee31b3b394b9c987f7f7ec245964f2deace (patch) | |
tree | 877dc63e4558525961548d153f954e96c164c904 /md | |
parent | e3917966f16485f85b023f1ae36bc44b4a5f8171 (diff) | |
download | md-content-8d2aaee31b3b394b9c987f7f7ec245964f2deace.tar.gz md-content-8d2aaee31b3b394b9c987f7f7ec245964f2deace.zip |
Add macro
Diffstat (limited to 'md')
-rw-r--r-- | md/notes/undefined_c/titles.md | 34 |
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 |