Documentation
¶
Overview ¶
Package c provides convenience helpers for C interop. It bridges C's null-terminated strings and raw pointers with So's string and slice types.
Index ¶
- func Alignof[T any]() int
- func Alloca[T any](n int) *T
- func Assert(cond bool, msg string)
- func Bytes(ptr *byte, n int) []byte
- func PtrAdd[T any](ptr *T, offset int) *T
- func PtrAs[T any](ptr any) *T
- func PtrAt[T any](ptr *T, index int) *T
- func Raw(code string)
- func Sizeof[T any]() int
- func Slice[T any](ptr *T, len int, cap int) []T
- func String[T Char | ConstChar](ptr *T) string
- func Val[T any](expr string) T
- func Zero[T any]() T
- type Char
- type ConstChar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Alloca ¶
Alloca allocates an array of the given length on the stack and returns a pointer to it.
func Assert ¶
Assert aborts the program with the given message if the condition is not true. If assertions are disabled, does nothing.
assert((cond) && msg)
func Bytes ¶
Bytes wraps a raw byte pointer and length into a []byte without copying. If ptr is nil, returns nil.
(so_Slice){ptr, n, n}
func PtrAt ¶
PtrAt returns a pointer to the element at the given index in an array or slice.
&ptr[index]
func Slice ¶
Slice wraps a raw pointer and length into a []T without copying. If ptr is nil, returns nil.
(so_Slice){ptr, len, cap}
Types ¶
Click to show internal directories.
Click to hide internal directories.