Standard Library · ffi
attribute repr
Gives a value struct C's field layout.
since 0.1.0-alpha.1linuxwindowswasm
Overview
The only layout is "C". The struct stays an ordinary Leviathan struct; the attribute checks that every field has a C type and records the layout used when the struct crosses to C.
Examples
A C-layout struct
uses ffi;
use io::console;
use ffi;
@repr("C")
struct Packet {
int32 a;
int8 b;
}
comptime int size = ffi::sizeOf::<Packet>();
console.writeln(size);
8
Fields
layout
string layoutThe layout name; must be "C".