3 ms·
I was reading GCC builtins documentation and suddenly realized I can make a generic print function at which you can throw variables of arbitrary types and sizes
by exebook 6y ago
I was reading GCC builtins documentation and suddenly realized I can make a generic print function at which you can throw variables of arbitrary types and sizes, even arrays! It is super cool, almost like console.log() in JavaScript or print in Python.
- rurban 6y agoThen read the clang builtins, much better. With clang you can do C++ stuff, not only _Generic, but overloadable. Which is useful for arbitrary struct support for this problem. https://clang.llvm.org/docs/AttributeReference.html#overloadable https://clang.llvm.org/docs/AttributeReference.html#overload... gcc's compile-time expression chooser is also severely limited compared to clang.
- exebook 6y agoThanks, very interesting. Unfortunately my main compiler is TinyC so I am limited to those extensions that it supports, although TinyC's community is open to ideas and may be they can add missing bits eventually.