跳转到内容
语言参考Zig 0.17.0官方原文

标识符必须以字母或下划线开头,后面可以跟任意数量的字母、数字或下划线。标识符不能与关键字相同。参见关键字参考。

字符串标识符语法

需要使用不满足这些要求的名称时,例如与外部库链接时,可以使用 @"" 语法。

identifiers.zig
const @"identifier with spaces in it" = 0xff;
const @"1SmallStep4Man" = 112358;
const c = @import("std").c;
pub extern "c" fn @"error"() void;
pub extern "c" fn @"fstat$INODE64"(fd: c.fd_t, buf: *c.Stat) c_int;
const Color = enum {
red,
@"really red",
};
const color: Color = .@"really red";