> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: FFI
icon: memory-stick
---

# <ApiPageIcon icon="memory-stick" />FFI

<ApiExposes data="[{&#x22;k&#x22;:&#x22;NAMESPACE&#x22;,&#x22;c&#x22;:&#x22;fn&#x22;,&#x22;s&#x22;:&#x22;ffi&#x22;,&#x22;h&#x22;:&#x22;#ffi-1&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;h&#x22;:&#x22;#ffictype&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;ffi.cb*&#x22;,&#x22;h&#x22;:&#x22;#fficb&#x22;}]" />

<Heading level={2} id="ffi-1">
  ffi

  <ApiTag label="global table" />
</Heading>

The `ffi` library lets you call external C functions and use C data structures from pure Lua code.
To use this library, add `ffi` to the `requirements` section of `extension.json`.

<ApiMembers>
  <ApiMember kind="prop" name="ffi.C" summary="Default C namespace. Resolves symbols from the default set of loaded libraries." ret="[[{&#x22;s&#x22;:&#x22;ffi.C.namespace&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" />

  <ApiMember kind="prop" name="ffi.arch" summary="Target architecture string (e.g. `&#x22;x64&#x22;`)." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]]" />

  <ApiMember kind="prop" name="ffi.os" summary="Target OS name string (e.g. `&#x22;Windows&#x22;`)." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]]" />

  <ApiMember kind="fn" name="ffi.cdef" summary="Adds multiple C declarations for types, external variables, or external functions. `def` is a string holding one or more C declarations, separated by semicolons. Additional arguments substitute `$` placeholders in parameterized declarations, in order." args="def, params?, ...?" sig="[{&#x22;s&#x22;:&#x22;ffi.cdef&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;def&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;params&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;unknown&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;def&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}],&#x22;d&#x22;:&#x22;C declarations to parse and add to the FFI.&#x22;},{&#x22;n&#x22;:&#x22;params&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Optional parameters for parameterized type definitions.&#x22;,&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;unknown&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true}]" />

  <ApiMember kind="fn" name="ffi.load" summary="Loads the dynamic library at the given path or name and returns a new C library namespace. On POSIX systems, `global=true` makes symbols globally visible. The flag is ignored on Windows." args="name, global?" sig="[{&#x22;s&#x22;:&#x22;ffi.load&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;name&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;global&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.C.namespace&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.C.namespace&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;name&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}],&#x22;d&#x22;:&#x22;Library path or name to load.&#x22;},{&#x22;n&#x22;:&#x22;global&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}],&#x22;d&#x22;:&#x22;Whether to also load symbols into the global C namespace.&#x22;,&#x22;o&#x22;:true}]" returns="[{&#x22;n&#x22;:&#x22;clib&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.C.namespace&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.new" summary="Creates a new C data object with the given C type and optional initial value. For VLAs, `nelem` specifies the number of elements." args="ct, nelem?, init?, ...?" sig="[{&#x22;s&#x22;:&#x22;ffi.new&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;nelem&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;init&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;unknown&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C type specifier (declaration string, ctype, or cdata).&#x22;},{&#x22;n&#x22;:&#x22;nelem&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;Number of elements for variable-length arrays.&#x22;,&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;init&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Initial value or initializer list.&#x22;,&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;unknown&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true}]" returns="[{&#x22;n&#x22;:&#x22;cdata&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.typeof" summary="Creates a C type object for the given C type specifier. Caching the result of `ffi.typeof` and using it repeatedly is more efficient than passing strings directly." args="ct, params?, ...?" sig="[{&#x22;s&#x22;:&#x22;ffi.typeof&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;params&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;unknown&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffictype&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffictype&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C type specifier.&#x22;},{&#x22;n&#x22;:&#x22;params&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Optional parameters for parameterized types.&#x22;,&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;unknown&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true}]" returns="[{&#x22;n&#x22;:&#x22;ctype&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffictype&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.cast" summary="Casts a C data object to a different C type. This is a low-level, unsafe operation — no bounds or type checking is performed." args="ct, init" sig="[{&#x22;s&#x22;:&#x22;ffi.cast&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;init&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;Target C type to cast to.&#x22;},{&#x22;n&#x22;:&#x22;init&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;C data object or value to cast.&#x22;}]" returns="[{&#x22;n&#x22;:&#x22;cdata&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.metatype" summary="Attaches a metatable to a C type, enabling Lua-style OOP on C structures. Only one metatable can be attached per type. This cannot be changed afterwards." args="ct, metatable" sig="[{&#x22;s&#x22;:&#x22;ffi.metatype&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;metatable&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;table&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/table#table-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffictype&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffictype&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C type to attach the metatable to.&#x22;},{&#x22;n&#x22;:&#x22;metatable&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;table&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/table#table-1&#x22;}],&#x22;d&#x22;:&#x22;Metatable to attach.&#x22;}]" returns="[{&#x22;n&#x22;:&#x22;ctype&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffictype&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]}]" />

  <ApiMember kind="fn" name="ffi.gc" summary="Attaches a finalizer to a C data pointer, called when it is garbage collected. Pass `nil` as the finalizer to remove a previously set finalizer." args="cdata, finalizer?" sig="[{&#x22;s&#x22;:&#x22;ffi.gc&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;cdata&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;finalizer&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;function&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#function&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;cdata&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C data object to attach the finalizer to.&#x22;},{&#x22;n&#x22;:&#x22;finalizer&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;function&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#function&#x22;}],&#x22;d&#x22;:&#x22;Function called with `cdata` when it is collected. Pass `nil` to remove.&#x22;,&#x22;o&#x22;:true}]" returns="[{&#x22;n&#x22;:&#x22;cdata&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]}]" />

  <ApiMember kind="fn" name="ffi.sizeof" summary="Returns the size in bytes of the given C type or C data object. Returns `nil` for types of unknown or variable size (e.g. incomplete types)." args="ct, nelem?" sig="[{&#x22;s&#x22;:&#x22;ffi.sizeof&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;nelem&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;nil&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#nil&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;nil&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#nil&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C type or C data to measure.&#x22;},{&#x22;n&#x22;:&#x22;nelem&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;Number of elements for VLA size calculation.&#x22;,&#x22;o&#x22;:true}]" returns="[{&#x22;n&#x22;:&#x22;size&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;nil&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#nil&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.alignof" summary="Returns the minimum required alignment in bytes for the given C type." args="ct" sig="[{&#x22;s&#x22;:&#x22;ffi.alignof&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C type to query alignment for.&#x22;}]" returns="[{&#x22;n&#x22;:&#x22;align&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;Alignment requirement in bytes.&#x22;}]" nodiscard />

  <ApiMember kind="fn" name="ffi.offsetof" summary="Returns the byte offset of a field within a C struct or union. For bit fields, also returns the bit position and bit size." args="ct, field" sig="[{&#x22;s&#x22;:&#x22;ffi.offsetof&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;field&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}],[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C struct or union type to query.&#x22;},{&#x22;n&#x22;:&#x22;field&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}],&#x22;d&#x22;:&#x22;Name of the field.&#x22;}]" returns="[{&#x22;n&#x22;:&#x22;ofs&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]},{&#x22;n&#x22;:&#x22;bpos&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]},{&#x22;n&#x22;:&#x22;bsize&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.istype" summary="Checks whether `obj` is a C data object compatible with the C type `ct`." args="ct, obj" sig="[{&#x22;s&#x22;:&#x22;ffi.istype&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ct&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;obj&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ct&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.ct*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffi-ct&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}],&#x22;d&#x22;:&#x22;C type to test against.&#x22;},{&#x22;n&#x22;:&#x22;obj&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Value to test.&#x22;}]" returns="[{&#x22;n&#x22;:&#x22;status&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.errno" summary="Gets or sets the OS error number (errno). If `newerr` is given, sets errno to that value and returns the previous value. C runtime `errno` is distinct from Win32 `GetLastError`." args="newerr?" sig="[{&#x22;s&#x22;:&#x22;ffi.errno&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;newerr&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;newerr&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;New errno value to set.&#x22;,&#x22;o&#x22;:true}]" returns="[{&#x22;n&#x22;:&#x22;err&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]}]" nodiscard />

  <ApiMember kind="fn" name="ffi.string" summary="Converts a C data pointer to a Lua string. If `len` is given, copies exactly that many bytes; otherwise copies until the first null byte." args="ptr, len?" sig="[{&#x22;s&#x22;:&#x22;ffi.string&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ptr&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;len&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ptr&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Pointer to the data to convert.&#x22;},{&#x22;n&#x22;:&#x22;len&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;Number of bytes to copy. Defaults to `strlen(ptr)`.&#x22;,&#x22;o&#x22;:true}]" returns="[{&#x22;n&#x22;:&#x22;str&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]}]" />

  <ApiMember kind="fn" name="ffi.copy" summary="Copies `len` bytes from `src` to `dst`. If given a string as `src` and no `len`, copies the full string including the null terminator." args="dst, src, len" sig="[{&#x22;s&#x22;:&#x22;ffi.copy&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;dst&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;src&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;len&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;dst&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Destination pointer.&#x22;},{&#x22;n&#x22;:&#x22;src&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Source pointer or string.&#x22;},{&#x22;n&#x22;:&#x22;len&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;Number of bytes to copy.&#x22;}]" />

  <ApiMember kind="fn" name="ffi.fill" summary="Fills `len` bytes starting at `dst` with the byte value `c` (default 0)." args="dst, len, c?" sig="[{&#x22;s&#x22;:&#x22;ffi.fill&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;dst&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;len&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;[, &#x22;},{&#x22;s&#x22;:&#x22;c&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;dst&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Destination pointer.&#x22;},{&#x22;n&#x22;:&#x22;len&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;Number of bytes to fill.&#x22;},{&#x22;n&#x22;:&#x22;c&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;Byte value to fill with. Defaults to `0`.&#x22;,&#x22;o&#x22;:true}]" />

  <ApiMember kind="fn" name="ffi.abi" summary="Checks for ABI parameters of the target platform. Common params: `&#x22;32bit&#x22;`, `&#x22;64bit&#x22;`, `&#x22;le&#x22;`, `&#x22;be&#x22;`, `&#x22;fpu&#x22;`, `&#x22;softfp&#x22;`, `&#x22;hardfp&#x22;`, `&#x22;eabi&#x22;`, `&#x22;win&#x22;`." args="param" sig="[{&#x22;s&#x22;:&#x22;ffi.abi&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;param&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;param&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}],&#x22;d&#x22;:&#x22;ABI parameter string to test.&#x22;}]" returns="[{&#x22;n&#x22;:&#x22;status&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;}]}]" />

  <ApiMember kind="type" name="ffi.ct*" ret="[[{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/ffi#ffictype&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;ffi.cdecl&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;},{&#x22;s&#x22;:&#x22;|&#x22;},{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" />
</ApiMembers>

## ffi.ctype\*<ApiTag label="object type · callable" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;userdata&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#userdata&#x22;}]" />

Represents a C type object created by `ffi.typeof`. Callable to construct new `ffi.cdata*` instances.

<ApiMembers>
  <ApiMember kind="ctor" name="ffi.ctype*(init, ...)" syntax="ffi.ctype*(init?, ...?)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;init&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;init&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true}]" />

  <ApiMember kind="ctor" name="ffi.ctype*(nelem, init, ...)" syntax="ffi.ctype*(nelem?, init?, ...?)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;ffi.ctype*&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;nelem&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;init&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;...&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;nelem&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;init&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true},{&#x22;n&#x22;:&#x22;...&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;o&#x22;:true}]" />
</ApiMembers>

## ffi.cb\*<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;ffi.cdata*&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ffi.cdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;*&#x22;}]}]" />

Represents a C callback object. Use `:free()` to release it and `:set()` to replace the Lua function.

<ApiMembers>
  <ApiMember kind="method" name="ffi.cb*:free" summary="Releases the resources associated with a C callback object. The callback must not be called after this — doing so is undefined behavior." args="" sig="[{&#x22;s&#x22;:&#x22;ffi.cb*:free&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" />

  <ApiMember kind="method" name="ffi.cb*:set" summary="Replaces the Lua function of an existing C callback object with a new one. This avoids the overhead of allocating a new callback." args="func" sig="[{&#x22;s&#x22;:&#x22;ffi.cb*:set&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;func&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;function&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#function&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;func&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;function&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#function&#x22;}],&#x22;d&#x22;:&#x22;New Lua function to use for the callback.&#x22;}]" />
</ApiMembers>
