Skip to content

IMPORT


External linkage attribute for public data located in DLL's

Syntax

` Extern Import symbolname[( subscripts)] [ alias "aliasname"] [ as DataType] [, ...]

`

Description

Is used only (with the Extern keyword) in external modules to access global variables from Win32 DLLs: the variable names will be added to the dynamic library import list so that their addresses can be fixed at run-time.

This is due to the level of indirection on any such access: an implicit pointer dereference.

Examples

start GeSHi

/* mydll.c :
    compile with
      gcc -shared -Wl,--strip-all -o mydll.dll mydll.c
*/
__declspec( dllexport ) int MyDll_Data = 0x1234;

end GeSHi

start GeSHi

vb
/'  import.bas :
    Compile With
      fbc Import.bas
'/
#inclib "mydll"

Extern Import MyDll_Data Alias "MyDll_Data" As Integer

Print "&h" + Hex( MyDll_Data )

' Output:
' &h1234

end GeSHi

Dialect Differences

  • Not available in the -lang qb dialect unless referenced with the alias __Import.

Differences from QB

  • New to FreeBASIC

See also

  • Extern

Back to DocToc

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft