Try it; it uses the gcc __builtin methods and automatically detects the type for you as much as possible and makes a simple DEBUG macro where you do not need to specify the type. Of course you can compare typeof (x) with a floating point, etc. Etc.
#define DEBUG(x) \ ({ \ if (__builtin_types_compatible_p (typeof (x), int)) \ fprintf(stderr,"%d\n",x); \ else if (__builtin_types_compatible_p (typeof (x), char)) \ fprintf(stderr,"%c\n",x); \ else if (__builtin_types_compatible_p (typeof (x), char[])) \ fprintf(stderr,"%s\n",x); \ else \ fprintf(stderr,"unknown type\n"); \ })
Ben stott
source share