#define 전처리문 ()
형태로 작성한다.#define NINE 9
의 형태로 작성되었다.#include <iostream>
using namespace std;
#define NINE 9 // NINE을 9 취급한다.
int main() {
cout << NINE << endl;
}
#define NINE "Hello world"
#define MAX(a,b) ((a>b) ? a:b)
#include<iostream>
using namespace std;
#define APPLE
int main()
{
#ifdef APPLE // APPLE라는 매크로가 정의가 되어있으면 ifdefine
cout << "exist" << endl;
#endif
#ifndef APPLE // APPLE라는 매크로가 정의가 되어있지 않으면 ifnotdefine
cout << "not-exist" << endl;
#endif
}
정의가 되어있으므로 ifndef는 흐리게 나온다
전처리기는 전처리기를 사용한 파일에만 적용이 된다.