[C] #if #elif #else #endif
#include<stdio.h>
void hello()
{
printf("hello1.h : Hello Everbody \n");
}
#include <stdio.h>
void hello() {
printf("hello2.h : Hello, Hello! \n");
}
#include<stdio.h>
void hello() {
printf("hello3.h : Everybody!, Hello?\n");
}
/*------------------------------------------------------------------------------------------
@ Pratice C laguage
Author : SAM
Created : 30-03-2017
Modified : 30-03-2017
Language/ver : C in MSVS2015
Description : Practice
KEYWORD : #define #if #elif #else #endif
------------------------------------------------------------------------------------------*/
#define CONDITION 2
#if CONDITION == 1
#incldue "hello1.h"
#elif CONDITION ==2
#include "hello2.h"
#else
#incldue "hello3.h"
#endif
int main() {
hello();
return 0;
}
1. 조건부 컴파일러 #if #elif #else #endif 를 사용하여 컴파일러가 돌아가는 범위를 제한한다.
2. 먼저 각각의 헤더파일을 만들고 메인파일에서 #if #elif #else #endif 를 활용하여 원하는 헤더파일을 컴파일한다.
3. 이렇게 하면 장점이 원하는 부분의 헤더파일만 컴파일 하므로 시간과 메모리를 절약할 수 있다.