OxL Reference

fn zeroed

An all-zero value of a @c_layout type (C memset(&x, 0, sizeof x)); used to initialise out-parameters.

Example:

oxl✓ checked in CI
use std.ffi { zeroed, sizeOf }

import c "time.h" { gmtime_r, tm }

fn main() io {
  let secs: i64 = 86400
  var t: tm = unsafe { zeroed<tm>() }
  unsafe { gmtime_r(&secs, &var t) }
  print("{t.tm_year + 1900}-{t.tm_mon + 1}-{t.tm_mday}")
}
Output
1970-1-2
@intrinsic("ffi.zeroed") pub(api) unsafe fn zeroed<T>() -> T

Since. 1.0.0-beta

Returns

T

Effects

none declared (pure unless the body says otherwise)

Defined in: std/ffi/ffi.oxl:224

See also