* This looks surprising but I do not mind.
** Hmm... are you sure this compiles?
*** Is it bitrot on on your disk or did you really write that?
**** This belongs to hell, do you belong to hell?
***** Your soul is cursed, be damned in D00M!
* assert(!"not reachable");
* #define ArgvLen(...) sizeof((char[]){ __VA_ARGS__ })
* #define F(x) { #x, &cmd_##x }
FnMap map[] = { F(help), F(list), F(add), F(del) };
* return 0
|| parse_command_name(&buffer, &cmd)
|| parse_int_spec(&buffer, &intspec)
|| pasre_argument_list(&buffer, &arglist)
|| parse_extra_flags(&buffer, &flags)
? -1 : 0;
* #define C 'C',(int)
#define B 'B',(i64)
#define D 'D',(i64)
#define O 'O',(i64)
#define X 'X',(i64)
#define E 'E'
#define S 'S',
myprint("hello %\n", S"john");
* #define kHz (1000UL)
#define MHz (1000UL*kHz)
* #define KB (1024UL)
#define MB (1024UL*KB)
#define GB (1024UL*MB)
* #define KB (1000UL)
#define MB (1000UL*KB)
#define GB (1000UL*MB)
* #define INFO "a tool to poke around"
#define AUTHOR "The Dude <
[email protected]>"
/* but actually never used in the program */
* #define Len(x) (sizeof(x) / sizeof(*x))
#define Min(x, y) ((x) < (y) ? (x) : (y))
#define Max(x, y) ((x) > (y) ? (x) : (y))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define Sign(x) ((x) > 0 ? 1 : (x) < 0 ? -1 : 0)
* /* avoids integer overlow */
#define Dist(x, y) ((x) > (y) ? (x) - (y) : (y) - (x))
#define Direc(x, y) ((x) < (y) ? 1 : (x) > (y) ? -1 : 0)
* #define Bit(arr, i) ((arr)[(i) / sizeof(arr) * 8] & 1<<((i) % (sizeof(arr)*8)))
* enum { B00000000, B00000001, B00000010, B00000011, [...] };
* #define tostr(n) _tostr((char[50]){ 0 }, 50, n)
* # cross compiling for multiple targets on a same project
$ cat arm-none-eabi/Makefile
O = arm-none-eabi.o
OBJ = ../main.$O
all: main.elf
.SUFFIXES: .$O
.c.$O:
arm-none-eabi-gcc ${CFLAGS} -c -o $@ $<
main.elf: ${OBJ}
arm-none-eabi-gcc ${LDFLAGS} -o $@ ${OBJ}
$ ls -P
./arm-none-eabi/
./riscv64-unknown-elf/
./xtensa-esp32-elf/
./main.arm-none-eabi.o
./main.xtensa-esp32-elf.o
./main.riscv64-unknown-elf.o
./main.c