自己使用DEBUG巨集經歷

2021-06-10 22:24:07 字數 916 閱讀 6068

(本文是自己在學習是總結的自己所用到的幾點知識,僅僅用作自己學習筆記使用,以後若有需要會更新)

#define dbga(fmt, args...) printf(fmt"\n", #args);

#define dbgd(fmt, args...) printf("%s"fmt"\n",__function__, #args);

#define dbgc(fmt, args...) printf(fmt"\n", ##args);

#define dbgb(fmt, args...) printf("[%s]: hello"fmt"\n", __function__, #args);

int main(void)

char str = "helloeveryone";

dbga("%s", "hello", __function__, dbga, str);

dbgd("%s", "hello",__function__, dbgd, str);

dbgc("[%s]: %s, %s",__function__, "dbgc", str);    //此處是帶##的

dbgb("%s", __function__, dbgb);

列印結果:

"hello", __function__, dbga, str

main"hello", __function__, dbgd, str

[main]: dbgc, helloeveryone

[main]: hello__function__, dbgb

可以看出,帶#的基本上是按照字元替換來列印的(__function__就沒有列印出函式名稱稱),如果想列印還數名稱的話,可以在巨集定義的時候加入__function__

我覺得用##還是比較好些

debug內建巨集

編譯器內建巨集 先介紹幾個編譯器內建的巨集定義,這些巨集定義不僅可以幫助我們完成跨平台的原始碼編寫,靈活使用也可以巧妙地幫我們輸出非常有用的除錯資訊。ansi c標準中有幾個標準預定義巨集 也是常用的 line 在源 中插入當前源 行號 file 在原始檔中插入當前源檔名 date 在原始檔中插入當...

自己的經歷

從02年剛開始畢業,哪個時候什麼都不懂 對語言就是pascle c foxpro2.5 c語言還是自己學習的,大學四年有很多地方很充實,也很無奈啊。開始找工作的時候 有個要計算機老師,他是給人家培訓計算機等級考試的,當時面試可以,等上機考試,可以說什麼也不會,打字還是拼音,人家問,五筆不會嗎。我說不...

iOS巨集 自己使用,持續更新

直接從rgb取顏色 rgb 0xff00ff define uicolor from rgb rgbvalue uicolor colorwithred float rgbvalue 0xff0000 16 255.0 green float rgbvalue 0xff00 8 255.0 blue...