| .. | ||
| kprint_colors.h | ||
| kprint_format.h | ||
| kprint_format.md | ||
| kprint.c | ||
| kprint.h | ||
| kprintf.c | ||
| kprintf.h | ||
| README.md | ||
kprintf
It is just my variant of printf.
kprint
I don't really like printf function (and its variants), so i made safer and more convinient replacement.
| function | returns | arguments |
|---|---|---|
| kprint | void/throw | kprint_format, void*, kprint_format, void*... |
| ksprint | Maybe<char*> | kprint_format, void*, kprint_format, void*... |
| kfprint | Maybe | FILE*, kprint_format, void*, kprint_format, void*... |
how to use it:
-
format construction:
kprint_format fmt= kprint_fgColor | kprint_bgColor | kprint_fdataFmt | flags | ktid;- fgColor and bgColor can be set to change console output color
- you should set dataFormat for
int/uint/float/char*arguments and ktid for other types - flags can be set to modify TypeDescriptor.toString() behavior
- don't forget to set TypeDescriptor.toString when registering type, or kprint will crash
-
using base type arguments:
you can just put them into a functionkprint(kprint_fmtHex | kprint_fmtUppercase | kprint_fmtWithPrefix, 255);output: 0xFF
-
using other registered types:
should be sent as pointersMaybe m=MaybeNull; kprint(kprint_fgBlue | kprint_fmtString, "Maybe: ", kprint_fgGreen | ktid_MaybePtr, &m);output: Maybe: {value={0, ktid_Null}}