zig
zig copied to clipboard
"error: redefinition of label 'blk'" when translating C macro
Zig Version
0.10.0-dev.4249+11dce7894
Steps to Reproduce
I don't have a fully reproducible case yet. This is happening when attempting to translate part of the PostgreSQL 15 headers.
Expected Behavior
No compilation error.
Actual Behavior
I'm getting the following error:
$ zig build test
zig-cache/o/1e6cc7956eea0b29702f59fbeba95335/cimport.zig:15598:13: error: redefinition of label 'blk'
_ = blk: {
^~~
zig-cache/o/1e6cc7956eea0b29702f59fbeba95335/cimport.zig:15597:12: note: previous definition here
return blk: {
^~~
src/postgresql/parser.zig:4:16: error: C import failed: AnalysisFail
const parser = @cImport({
^~~~~~~~
referenced by:
test.can use parser: src/postgresql/parser.zig:26:5
remaining reference traces hidden; use '-freference-trace' to see all reference traces
error: test...
Inspecting file at e6cc7956eea0b29702f59fbeba95335/cimport.zig:15598 I see that the following was attempted to be translated:
pub inline fn LSN_FORMAT_ARGS(lsn: anytype) uint32 {
return blk: {
_ = blk: {
_ = AssertVariableIsOfTypeMacro(lsn, XLogRecPtr);
break :blk @import("std").zig.c_translation.cast(uint32, lsn >> @as(c_int, 32));
};
break :blk @import("std").zig.c_translation.cast(uint32, lsn);
};
}
The actual macro looks like this:
/*
* Handy macro for printing XLogRecPtr in conventional format, e.g.,
*
* printf("%X/%X", LSN_FORMAT_ARGS(lsn));
*/
#define LSN_FORMAT_ARGS(lsn) (AssertVariableIsOfTypeMacro((lsn), XLogRecPtr), (uint32) ((lsn) >> 32)), ((uint32) (lsn))
Hopefully someone else is able to make a smaller reproducible test.