Pragmas
Pragmas are compiler directives written as {.pragmaName.}.
Pragmas are compiler directives written as {.pragmaName.}.
{.noSideEffect.} / func {.raises: [].}, {.tags: [].}, {.forbids: [].} Thread-safety w.r.t. GC memory Return value may be ignored {.deprecated: "use X".}
{.importc.}, {.exportc.}, {.header.}, {.dynlib.}, {.cdecl.}
{.importcpp.}, {.importobjc.}, {.importjs.} C++/ObjC/JS FFI {.emit: "...".} Inject raw target code
{.compile: "x.c".}, {.passC.}, {.passL.}, {.link.} Enum requires qualification {.final.}, {.inheritable.}
Borrow implementation for distinct types {.packed.}, {.union.}, {.align(16).}, {.bycopy.}, {.byref.} Static local variable Compile-time only proc or variable {.noinit.}, {.requiresInit.} {.push....} / {.pop.} Apply pragmas to a region
{.checks: off.}, {.boundChecks: off.}, {.overflowChecks: off.} Disable checks locally
{.hint[XDeclaredButNotUsed]: off.}, {.warning: "msg".}, {.error: "msg".} {.experimental: "feature".} Opt into experimental features Suppress unused warnings Proc never returns
Proc may be used as a thread entry point {.locks: 0.} Lock levels (deprecated) Non-owning ref (ARC/ORC optimization)
Type can't form cycles (ORC optimization) Skip destructor injection {.size: sizeof(cint).} Enum size for FFI
{.push checks: off, inline.}
proc hotLoop() = discard
{.pop.}
# User-defined pragmas
{.pragma: myExport, exportc, dynlib, cdecl.}
proc api() {.myExport.} = discard
# Macro pragmas: any macro can be used as a pragma
macro logCalls(p: untyped): untyped = ...
proc work() {.logCalls.} = discard