Skip to content

LIB


在声明中指定可以找到子程序或函数的库。

语法

vb
declare { sub | function } proc_name lib "libname" [ alias "symbol_name" ] ( arguments list ) as return_type

extern "mangling" lib "libname"

declarative statements

end extern

type T

as integer dummy
declare constructor lib "libname" [ alias "symbol_name" ] ( arguments list )

end type

描述

SubFunction 声明中,以及类方法声明(包括构造函数和析构函数)中,lib 指示包含该函数的库。以这种方式指定的库在链接时就像使用了 #inclib "libname"-l libname 一样。

lib 也可以与 Extern ... End Extern 块 一起使用,为其中的所有声明指定一个 lib

示例

start GeSHi

vb
'' mydll.bas
'' compile with:
''   fbc -dll mydll.bas

Public Function GetValue() As Integer Export
  Function = &h1234
End Function

end GeSHi

start GeSHi

vb
Declare Function GetValue Lib "mydll" () As Integer

Print "GetValue = &h"; Hex(GetValue())

' Expected Output :
' GetValue = &h1234

end GeSHi

与 QB 的差异

  • FreeBASIC 新增功能

参见

  • Declare
  • #inclib

返回 目录

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