关于#ifdef—DEBUGE 或者#ifndef —DEBUGE

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:38:25
#ifdef—DEBUGE XXXX #else xxxx #endif的意思是说 如果定义了DEBUGE就XXXXX,那我想知道DEBUGE该在那里定义??

#include "iostream.h"
#define _DEGUGE
#undef _DEGUGE
int main()
{
#define _DEBUGE //你可以在这地方注释掉看效果
#ifdef _DEBUGE
cout<<"DEBUGE defined"<<endl;
#else
cout<<"DEBUGE not defined"<<endl;
#endif
return 0;
}

随便你在哪里定义,只是如果你在执行这段代码之前已经定义了DEBUGE那么就执行#ifdef后面的,如果没定义就执行#else后面的。