#include <iostream>using namespace std; #ifndef DEBUG#define LOG(log)#else#define LOG(log) cout << "File:" << __FILE__ << "/tLine:" << __LINE__ << "/t" << log <<endl#endif int main(){ int ia[3] = {1, 2, 3}; for (int i = 0; i < 3; i++) { LOG(ia[i]); }}
编译时使用gcc -O test.cpp -lstdc++ -DDEBUG就会Log信息
如果使用gcc -O test.cpp -lstdc++就没有Log信息