4 ms·
Plug for a tiny header library I wrote https://github.com/rtaycher/debug_print_h https://github.com/rtaycher/debug_print_h It's a little thing for simple prin
by rat87 11y ago
Plug for a tiny header library I wrote
https://github.com/rtaycher/debug_print_h https://github.com/rtaycher/debug_print_h
It's a little thing for simple printf debugging. I got tired as hell of using formatting strings. It prints line, file, and function, expression and value. Since it stands out /greppable it's easier to delete then random printfs.
It has support for different colors(to make things stand out) and uses c99 _Generic to support different types with a single "function" and c initializers for named arguments. It supports basic c types and you can sort of extend it by modyfing the header(unfortunately I couldn't find anything cleaner using c).
C99 only (works on gcc>4.9 (due to use of designated initializers) and llvm/clang >3.3 (maybe earlier but I tested it with 3.3)
I was hoping to support msvc but it looks like Microsoft hasn't implemented _Generic yet.
- kyberias 11y agoBut... isn't _Generic part of C11, not C99? You actually require C11. Big difference.
- rat87 11y agoOops. You're absolutely right it's C11.
- kyberias 11y agoYeah, I wondered about that because I thought VC's C99 implementation is _relatively_ useful but again C11 might never arrive there.
- rat87 11y agoLooks I'm wrong again, it's been a while since I wrote it it also uses typeof gcc/llvm extension, there might be a way to fix that but since msvc lacks _Generic I didn't bother. I was also hoping to support c++ but c++ doesn't do designated initializers.