본문 바로가기

카테고리 없음

C언어_매크로함수

#define DEBUG2

int main(int argc, char **argv){
	int num = 2;

#ifdef DEBUG2
	fprintf(stdout, "Debuging... num address: %p\n", &num);
#endif

	fprintf(stdout, "num: %d\n", num);
}

 

[결과 분석]

(원본 코드)

(#define DEBUG2 주석처리시)



DEBUG2가 정의되어 있으면 다음과 같이 num2의 address를 출력하는 문장이 출력되고, 정의가 되어있지 않는 경우, 출력이 안되는 것을 확인할 수 있었다.