Linux C 中连接操作符##
打印信息:
***************************************************
?File : test.c Funtion : test1 Line : 11???????? Integer : 100
?File : test.c Funtion : test2 Line : 16???????? String : hello
***************************************************
?
#define DPRINT( fmt, args...) \
{ \
printf("File : %s Funtion : %s Line : %d? \t", __FILE__, __FUNCTION__, __LINE__ );\
printf( fmt, ##args );\
}
這樣定義宏有個(gè)問(wèn)題, 標(biāo)準(zhǔn)printf()函數(shù)有返回值, 只是我們很少用
另外一種定義:
#define DPRINT( fmt, args...)???? \
printf("File : %s Funtion : %s Line : %d? \t"fmt, __FILE__, __FUNCTION__, __LINE__ ,##args )
fmt不能為指針
*****************************************
const? char *s= "string";
printf(s);
*****************************************
是合法的,可以打印出string
但DPRINT(s)就不合法
posted on 2012-02-02 10:19?Neddy11 閱讀(...) 評(píng)論(...) 編輯 收藏轉(zhuǎn)載于:https://www.cnblogs.com/Neddy/archive/2012/02/02/2335399.html
總結(jié)
以上是生活随笔為你收集整理的Linux C 中连接操作符##的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: console程序显示彩色文字 .
- 下一篇: 平面设计师必备的十个技能