code

전 처리기 지시문 #if와 #ifdef의 차이점

codestyles 2020. 12. 10. 20:19
반응형

전 처리기 지시문 #if와 #ifdef의 차이점


다음 두 전 처리기 제어문의 차이점 (있는 경우)은 무엇입니까?

#if

#ifdef

다음을 수행하여 차이를 입증 할 수 있습니다.

#define FOO 0
#if FOO
  // won't compile this
#endif
#ifdef FOO
  // will compile this
#endif

#if기호 #ifdef확인 하고 기호 존재확인합니다 (값에 관계없이).


#ifdef FOO

다음에 대한 단축키입니다.

#if defined(FOO)

#if 다른 테스트 나 더 복잡한 전 처리기 조건에도 사용할 수 있습니다.

#if defined(FOO) || defined(BAR)

참고 URL : https://stackoverflow.com/questions/3802988/difference-between-preprocessor-directives-if-and-ifdef

반응형