Q : #if , #ifdef , #ifndef 的使用方法?
 
A : #1,#2,#3.
 
#1
#if condition(表达式1)
//程序段1
(#elif condition(表达式n)
//程序段n
)
...
(#else
//程序段3
)
#endif
说明 : 如果 表达式1(condition : true),则执行 程序段1,(否则如果 表达式2(condition : true),则执行 程序段n),(否则执行 程序段3).
 
#2
#ifdef macro(标识符1)
//程序段1
(#else
//程序段2
)
#endif
说明 : 如果 有定义标识符1(#define macro),则执行 程序段1,(否则执行 程序段2).
 
#3
#ifndef macro(标识符1)
//程序段1
(#else
//程序段2
)
#endif
说明 : 如果 没有定义标识符1(#define macro),则执行 程序段1,(否则执行 程序段2).与#2相反!

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2022-02-22
  • 2022-12-23
  • 2021-11-27
相关资源
相似解决方案