我的意思是,例如:
#define max(a,b) \ ({ typeof (a) _a = (a); \ typeof (b) _b = (b); \ DEBUG(( "%" __PRI_TYPE_PREFIX(a) > "%" __PRI_TYPE_PREFIX(b) "?",_a,_b)) \ <-- hypothetical _a > _b ? _a : _b; })
有可能吗?
解决方法 您可以使用C11的_Generic功能来执行此 *** 作,例如#define printf_dec_format(x) _Generic((x),\ char: "%c",\ signed char: "%hhd",\ unsigned char: "%hhu",\ signed short: "%hd",\ unsigned short: "%hu",\ signed int: "%d",\ unsigned int: "%u",\ long int: "%ld",\ unsigned long int: "%lu",\ long long int: "%lld",\ unsigned long long int: "%llu",\ float: "%f",\ double: "%f",\ long double: "%Lf",\ char *: "%s",\ voID *: "%p")#define print(x) printf(printf_dec_format(x),x)
(例子来自:Rob’s Programming Blog)
总结以上是内存溢出为你收集整理的c – __typeof变量和printf全部内容,希望文章能够帮你解决c – __typeof变量和printf所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)