Skip to content

怎么和c语言一样在定义结构体的时候用宏控制? #158

Closed Answered by vkensou
vkensou asked this question in 新手提问
Discussion options

You must be logged in to vote

在ziggit上问到一个方法:

const A = struct {
    a: i32,
    b: switch (@import("builtin").os.tag) {
        .windows => i32,
        else => void,
    },
};

void类型可以减少重复

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@vkensou
Comment options

@jiacai2050
Comment options

Comment options

You must be logged in to vote
4 replies
@jiacai2050
Comment options

@hshq
Comment options

@vkensou
Comment options

@jiacai2050
Comment options

Answer selected by jiacai2050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants