Lib

FreeBASIC

Lib
 
Specifies the library where a sub or function can be found as part of a declaration

Syntax

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


Description

In Sub or Function declarations, and also in class method declarations (including constructors and destructors), Lib indicates the library containing the function. Libraries specified in this way are linked in as if #Inclib "Libname" or -l libname had been used.

Lib can also be used with Extern ... End Extern Blocks to specifiy a Lib for all declarations inside.

Example

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

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


Declare Function GetValue Lib "mydll" () As Integer

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

' Expected Output :
' GetValue = &h1234


Differences from QB

  • New to FreeBASIC

See also