mirror of
https://github.com/ziglang/zig.git
synced 2024-11-28 16:12:33 +00:00
94039d66ed
Comptime fields are tied to the type and behave more like declarations so these operations cannot return anything useful for them.
17 lines
340 B
Zig
17 lines
340 B
Zig
const T = struct {
|
|
comptime a: u32 = 2,
|
|
};
|
|
pub export fn entry1() void {
|
|
@offsetOf(T, "a");
|
|
}
|
|
pub export fn entry2() void {
|
|
@fieldParentPtr(T, "a", undefined);
|
|
}
|
|
|
|
// error
|
|
// backend=stage2
|
|
// target=native
|
|
//
|
|
// :5:5: error: no offset available for comptime field
|
|
// :8:5: error: cannot get @fieldParentPtr of a comptime field
|