#define CHECK(condition) cout<<check failed:<<#condition<<endl;
上面這句宏,當(dāng)你 CHECK(myfunc()); 時(shí),假設(shè)myfunc返回false,會(huì)輸出:check failed:myfunc()
在宏中,#condition 是把參數(shù)轉(zhuǎn)換為字符串,這在打印log時(shí),可以很方便的打印出函數(shù)名稱(chēng)等等
這個(gè)大家可能都知道了,太小兒科了,但是,當(dāng)你在unicode下用的時(shí)候,很可能會(huì)出現(xiàn)亂碼
解決的辦法是 #condition 替換為 L## #conditon
新聞熱點(diǎn)
疑難解答
網(wǎng)友關(guān)注