#unable to translate C expr: unexpected token '{'

1 messages · Page 1 of 1 (latest)

tidal cedar
#
const std = @import("std");
const git = @cImport(@cInclude("git2.h"));

pub fn main() !void {
    _ = git.git_libgit2_init();
    var repo: ?*git.git_repository = undefined;
    _ = git.git_repository_open(&repo, ".");
    var statuses: ?*git.git_status_list = undefined;
    // ERROR
    const opts = git.GIT_STATUS_OPTIONS_INIT;
    _ = git.git_status_list_new(&statuses, repo, &opts);
    var len = git.git_status_list_entrycount(statuses);
    for (0..len) |i| {
        var entry = git.git_status_byindex(statuses, i);
        std.debug.print("{*}", .{entry});
    }
    _ = git.git_libgit2_shutdown();
    return;
}

Trying to use GIT_STATUS_OPTIONS_INIT.
https://github.com/libgit2/libgit2/blob/main/include/git2/status.h#L265

But I'm getting the following error.

unable to translate C expr: unexpected token '{'
pub const GIT_STATUS_OPTIONS_INIT = @compileError("unable to translate C expr: unexpected token '{'"); // /usr/include/git2/status.h:265:9

desert shuttle
#

GIT_STATUS_OPTIONS_INIT is {GIT_STATUS_OPTIONS_VERSION} which is {1}. These are not expressions, which are legal in a standalone context, so zig does not know how to translate them.

timber fog
#

it looks like that's meant to be used as a struct initializer, but zig can't know that without context

tidal cedar
tidal cedar