본문 바로가기
C++(홍정모의 따배씨++)

1.14 전처리기와의 첫 만남 Preprocessor

by 안장환 2021. 8. 5.

#define 매크로 ; 코드에서 교체해버림 *전처리기 안에서는 교체를 안함. 

#define MY_NUMBER 33   *대부분 대문자로 작성함.

 

#define

#define APPLE 10
int main()
{
#ifdef  APPLE
	cout << "Apple" << endl<< APPLE << endl;
#endif

#ifndef APPLE
	cout << "Orange" << endl;
#endif
	return 0;
}

멀티플랫폼 소프트웨어 개발할 때 사용. 

conditional compilation

 

#define 매크로의 효력범위는 그 해당 파일.

댓글