Special Attributes for Island
In addition to normal Custom Attributes and Predefined Aspects and Attributes provided by the compiler, the Elements compiler provides support for the special, attribute classes defined by the low-level Island RTL. In many cases, these attributes result in specific code or data to be generated in the executable, or in changed the compiler behavior.
Island Only
These attributes or aspects are available for the Island platform only. They're defined in the Island RTL.
VersionResource
Windows only: Defines the parameters for the PE version resource. Assembly level attribute, has these properties which are the direct equivalent to their version property.
property Copyright: String
property Description: String
property FileVersion: String
property CompanyName: String
property ProductName: String
property LegalTrademarks: String
property Title: String
property Version: String
StaticAddress
For low level targets, this places a static field to be equivalent to a memory address, when reading from it or writing to it, it will directly write to that memory address. Takes 1 IntPtr parameter containing the memory address.
InlineAsm
When defined on an external method, its body becomes a pure inline asm function. This attribute takes 4 parameters: asm containing the AT&T style asm. Constraints containing a clang compatible constraints string. SideEffects boolean to define if the asm block has side effects and align if it needs to be aligned.
CallingConvention
For i386 only, ignored on all other CPU types. Overrides the calling convention, takes 1 parameter of type CallingConvention and can be Default, FastCall, Stdcall or Cdecl.
- See
CallingConvention
for more information.
SymbolName
Overrides the name of a method or static field, takes a string parameter. By default Island uses name mangling to ensure methods don't have the same name, with this attribute a custom name can be provided. Useful for interop with other languages. Note that the compiler still applies some rules like adding an underscore before it, or adding @number after it for stdcall on Windows, these rules can be overriden by prefixing the symbol name with ascii character 1 (SymbolName(#1'MySymbol')).
- See
SymbolName
for more information.
DisableOptimizations
When applied to a method all optimizations in that function are disabled, even if the project is optimized.
DisableInlining
When applied to a method, this won't be inlined by the optimizer.
InReg
i386 only, ignored elsewhere. Can be set on a method, in which case its first parameter will pass via EAX instead of on the stack.
ThreadLocal
Can be set on a static field, when set this field will have its own copy for every thread instead of being a static.
SectionName
Overrides the PE/ELF section a method or field will be defined in. Takes a string parameter containing the new section name.
NoReturn
Marks a method as not returning for optimization purposes.
- See
NoReturn
for more information.
Weak
Marks a method or field as weak. When the linker encounters weak symbols it will merge them instead of fail, and a non weak version will take prescendence over a weak one.
LinkOnce
Like Weak, but linkonce symbols can be discarded if they are not referenced.
- See
LinkOnce
for more information.
Used
Can be applied to a type, method or static field and forces the compiler to link this symbol in, even if it's not referenced.
- See
Used
for more information.
Naked
When set on a method no prologue/epilogue, like a stackframe will be emitted for this method. Generally only combined with asm.
DllImport
For all platforms, imports a symbol from the given dynamic library. Takes a dllname as a parameter. Optionally an EntryPoint named argument can be set to define which symbol to look for.
- See
DllImport
for more information.
DllExport
For all platforms, exports a method, static field or type from the given dynamic library. This can also be set globally by setting the ExportAllTypes option. When used on methods or fields, the SymbolName attribute can be used to override the name which it gets exported with.
- See
DllExport
for more information.
Union
Changes a struct to work like a union, all fields are located at offset 0 and overlap eachother. The size of the struct is the size of the largest field.
- See
Union
for more information.
Packed
Changes the packing of the struct from the platform default to byte aligned.
- See
Packed
for more information.