-
比如c语言里这么定义: struct A
{
int a;
#if _WIN64
int b;
#endif
}; 我想这么写是因为有时候结构体里有空洞,我想手动填充上。 |
Beta Was this translation helpful? Give feedback.
Answered by
vkensou
Dec 11, 2024
Replies: 2 comments 6 replies
-
用一个编译时变量,控制选择哪个 struct, const X = if (condition) struct {
a: u64,
b: bool,
} else struct {
a: u64,
}; 编译时变量可以参考:https://en.liujiacai.net/2023/06/29/embed-git-commit-in-zig/ |
Beta Was this translation helpful? Give feedback.
2 replies
-
在ziggit上问到一个方法:
用 |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
jiacai2050
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在ziggit上问到一个方法:
用
void
类型可以减少重复