std.target
API summary (generated from the Beans source by npm run coverage): 10 package functions.
std.target tells you about the target you are compiling for. Every value is a
compile-time constant, so the compiler folds it into your program while it builds.
It is a native module, and its functions are typed in the checker; none take an
argument.
import std.targetBecause these are compile-time constants, they describe the selected target,
not necessarily the machine you are on. Under beansc run, the selected target is
always the host, so the two match there.
String facts
Section titled “String facts”triple() -> stringarch() -> stringos() -> stringenv() -> stringobject_format() -> stringendian() -> stringtriple()is the full target triple.arch()is the CPU architecture, likex86_64oraarch64.os()is the operating system.env()is the environment/ABI part of the triple.object_format()is the object file format.endian()is the byte order,littleorbig.
Number facts
Section titled “Number facts”pointer_bits() -> intpointer_size() -> intstack_align() -> intmax_simd_bits() -> intpointer_bits()is the pointer size in bits, like 64.pointer_size()is the pointer size in bytes, like 8.stack_align()is the stack alignment in bytes.max_simd_bits()is the widest SIMD vector in bits. It follows the--cpuand--featuresflags you build with, since those decide which vector widths are available.
import std.ioimport std.target
fn main() { io.println(target.arch()) // e.g. aarch64 io.println(target.pointer_size()) // e.g. 8 io.println(target.endian()) // e.g. little}See also
Section titled “See also”- Compile-time guide, how constants are folded during the build.
- std.encoding.binary, its
nativebyte order is resolved through this module.