c/c++使用#define,#ifdef,#endif将debug代码分离

#include <iostream>
#include<vector>
//#define MY_DEBUG //需要debug时去掉注释

using namespace std;

int main()
{
    cout << "no debug\n";
    vector<int> vec = {1,2,3,4,5,6,7,8,9,10};
    #ifdef MY_DEBUG
    cout << "in debug\n";
    for(auto a : vec){
        cout << a << endl;
    }
    #endif // MY_DEBUG
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/CreatorKou/p/9077883.html
今日推荐