Skip to content

#IF


预处理器条件指令

语法

vb
#if (expression)

' Conditionally included statements

#endif

说明

在编译时有条件地包含语句。

如果 expression 的值为真(非零),则包含 #if / #endif 块中的语句;如果 expression 的值为假(0),则排除(忽略)这些语句。

该条件指令与 If 条件语句的区别在于:#if 在编译时求值,而 If 在运行时求值。

示例

start GeSHi

vb
#define DEBUG_LEVEL 1
#IF (DEBUG_LEVEL >= 2)
  ' This line is not compiled since the expression is False
  Print "Starting application"
#ENDIF

end GeSHi

与 QB 的区别

  • FreeBASIC 新增

另请参阅

  • #define
  • #macro
  • #else
  • #elseif
  • #elseifdef
  • #elseifndef
  • #endif
  • #ifdef
  • #ifndef
  • #undef
  • defined
  • #assert

返回 目录

基于 FreeBASIC 官方文档翻译 如有侵权请联系我们删除
FreeBASIC 是开源项目,与微软公司无隶属关系