Skip to content

v3.gen.c.naming

fn c_name #

fn c_name(name string) string

c_name returns the C identifier used for a V symbol or type name.

fn is_libc_collision #

fn is_libc_collision(name string) bool

is_libc_collision reports whether name needs a prefix to avoid a libc symbol.

fn is_plain_identifier #

fn is_plain_identifier(name string) bool

is_plain_identifier reports whether name already contains only C identifier characters.

fn is_reserved_word #

fn is_reserved_word(name string) bool

is_reserved_word reports whether name needs a prefix to avoid a C reserved word.

fn sanitize #

fn sanitize(name string) string

sanitize converts a V symbol or type spelling into a C identifier spelling without applying reserved-word or libc collision prefixes.

fn type_name_part #

fn type_name_part(s string) string

type_name_part turns a C type or length expression into a fragment that is safe to embed inside a C identifier: * becomes ptr (so pointer payloads stay distinguishable), and every other character that is not a letter, digit, or _ becomes _. This keeps const-expression fixed-array lengths (e.g. segs + 1) and pointer return types (Foo*) from producing invalid identifiers such as Array_fixed_f32_segs_+_1 or __v_thread_arr_wait_Foo*.