Loading AI tools
来自维基百科,自由的百科全书
Zig是一个命令式、通用、静态类型、编译的系统编程语言。 [3] [4]以“强健性、最佳性以及可维护性”为核心理念。[5] [6]它支持编译时泛型与反射、交叉编译以及手动存储器管理。 [7]目标为改进 C语言[8] [9] ,同时参考从 Rust [10] [11]和其他语言。Zig 有许多低端程式设计的功能,例如紧致结构(成员间没有填充的结构)、任意大小的整数[12]以及多指针类型。[13]
此条目翻译品质不佳。 (2022年11月19日) |
Zig 最初的编译器是用 Zig 和 C++ 编写而成,以 LLVM 13[14] 为后端[15] [16]。这个编译器使用 MIT许可证 授权。Zig 编译器和 Clang 类似,能编译 C 与 C++(使用“zig cc”以及“zig c++”指令)[17],也为不同的平台提供头文件,包括 C标准函数库 和 C++标准函数库,因此 Zig 的 cc 与 c++ 子命令能直接作为交叉编译器。 [18] [19]
Zig 的开发由 Zig 软件基金会 (ZSF) 资助,该资金会是一家非营利公司,由 Andrew Kelley 担任总裁,也有雇佣一些全职员工,同时接受捐款。 [20] [21] [22]
const std = @import("std");
pub fn main() void {
std.debug.print("Hello, {s}!\n", .{"World!"});
}
pub fn main() void {
var node = LinkedList(i32).Node {
.prev = null,
.next = null,
.data = 1234,
};
var list = LinkedList(i32) {
.first = &node,
.last = &node,
.len = 1,
};
}
fn LinkedList(comptime T: type) type {
return struct {
pub const Node = struct {
prev: ?*Node,
next: ?*Node,
data: T,
};
first: ?*Node,
last: ?*Node,
len: usize,
};
}
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.