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

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

using namespace std;

int main()
{
    cout << "no debug
";
    vector<int> vec = {1,2,3,4,5,6,7,8,9,10};
    #ifdef MY_DEBUG
    cout << "in debug
";
    for(auto a : vec){
        cout << a << endl;
    }
    #endif // MY_DEBUG
    return 0;
}
原文地址:https://www.cnblogs.com/CreatorKou/p/9077883.html