Attributes
Spice offers the option to annotate single function or whole modules via attributes.
Optional value for bool attributes
For attributes of type bool, the value true can be omitted.
Module attributes¶
Available attributes¶
core.linker.flag: string (default: ""): Append linker flagcore.linux.linker.flag: string (default: ""): Append linker flag for Linuxcore.darwin.linker.flag: string (default: ""): Append linker flag for macOScore.windows.linker.flag: string (default: ""): Append linker flag for Windowscore.linker.additionalSource: string (default: ""): Compile and link an additional C/C++ source file, given relative to the annotated modulecore.compiler.alwaysKeepOnNameCollision: bool (default: false): Always keep the symbols of this source files when merging the name registries of multiple source files
Function attributes¶
| Spice | |
|---|---|
Available attributes¶
core.compiler.mangle: bool (default: true): Enable/disable name mangling for the annotated functioncore.compiler.mangledName: string: Set the mangled name for the annotated functioncore.compiler.redZone: bool: Allow or forbid the use of the red zone below the stack pointer in the annotated function. Overrides--no-red-zone, which sets the default for all other functions. Only x86_64 has a red zone. Code that runs while interrupts can push onto its stack, like a kernel, must not use it. The experimental TPDE backend always uses the red zone on x86_64, so it rejectsfalsethere (on AArch64, the value is accepted and has no effect)test: bool: Mark the annotated function as testtest.name: string: Set the name of the test (only functions or procedures with thetestattribute are considered as tests)test.skip: bool: Skip the annotated function (only functions or procedures with thetestattribute are considered as tests)
External declaration attributes¶
External declarations are not name-mangled by default, so they link against C symbols (and extern "C" C++ symbols)
without any attribute.
| Spice | |
|---|---|
Available attributes¶
core.compiler.mangle: bool (default: false): Enable/disable name mangling for the annotated declaration, e.g. to link against a Spice function from another compilation unitcore.compiler.mangledName: string: Set the linker symbol for the annotated declarationcore.linker.dll: bool: Enable linkage as dll (only relevant for Windows)
Struct attributes¶
Available attributes¶
core.compiler.alwaysEmitVTable: bool: Always emit a vtable for the annotated structcore.compiler.packed: bool: Pack the annotated struct
Interface attributes¶
Available attributes¶
core.compiler.fixedTypeId: int: Set a fixed type id for the annotated interface. Intended for internal use only.