Variables

Variables exposed by a C library can be declared inside a lib declaration using a global-variable-like declaration:

  1. lib C
  2. $errno : Int32
  3. end

Then it can be get and set:

  1. C.errno #=> some value
  2. C.errno = 0
  3. C.errno #=> 0

A variable can be marked as thread local with an attribute:

  1. lib C
  2. @[ThreadLocal]
  3. $errno : Int32
  4. end

Refer to the type grammar for the notation used in external variables types.