Repository navigation
Extern
Home › Modularizing › Extern
Declares a variable, array or object having external linkage
Extern [ Import ] symbolname[ (subscripts) ] [ Alias "aliasname" ] As DataType [, ...]symbolnamealiasname
Declares symbolname as an external name, meaning it is global to external modules including those to be compiled as static and dynamic libraries (DLLs).
Extern only declares variables, arrays and objects, and does not define them (different from Common or Dim). It also has the effect of making symbolname a shared name, meaning it is visible within procedures (see Shared). A symbolname declared as external name can be (re)defined (using Dim or Redim) only in a single external module.
If Alias is used, aliasname will be used as the external name rather than symbolname, and its case will be preserved.
Extern was added in order to support the C libraries.
If Import is used, the name will be added to the dynamic library import list so its address can be fixed at run-time.
- Windows does not support
Externwith a dynamic library (compiled with -dll or -dylib).
- Not available in the -lang qb dialect.
- New to FreeBASIC
'' extern1.bas
Extern Foo Alias "foo" As Integer
Sub SetFoo
foo = 1234
End Sub'' extern2.bas
Declare Sub SetFoo
Extern Foo Alias "foo" As Integer
Dim foo As Integer = 0
SetFoo
Print FooOutput:
1234Category: Modularizing
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing