3 ms·
Did not check the speed. I want to use it during debugging/developing so speed was not something I was thinking about. It is not a very elegant solution thanks
by exebook 6y ago
Did not check the speed. I want to use it during debugging/developing so speed was not something I was thinking about.
It is not a very elegant solution thanks to limitations of preprocessor __VAR_ARGS__. Basically there is a compiler builtin function __builtin_types_compatible_p() that checks if the argument is of a given type, then there is another builtin __builtin_choose_expr() that can do something with the result of the former. Using those two builtins I construct an array of type information and pass it to the actual printing function which is using <stdarg.h> and the array of type information to print stuff.