Build version information

Is it possible to access zig compiler version inside zig code?
I want something like “0.11.0-dev.980+601ab9a25” to be included inside my code.
I don’t see anything related in builtin.zig and grep didn’t find anything with ‘0.11.0’ string inside installed files.

Workaround would be to have build.zig to generate that information inside file which could be included later.

1 Like

Sorry this isn’t more helpful, but I know that zls does this somehow!

const builtin = @import("builtin");

in there you will find zig_version_string and zig_version.

See the language reference for more info: https://ziglang.org/documentation/0.10.1/#Compile-Variables

7 Likes