Skip to content

@cInclude does not complete C functions when build.zig is in a subdirectory #146

Open
@YDKK

Description

@YDKK

When build.zig is in a subdirectory, the included C functions are not completed.

Example directory structure:

  • build
    • build.zig
  • src
    • main.zig
    • test.h

In build.zig, add

exe.addIncludePath(.{
    .path = "../src",
});

test.h is

void some_func(int foo);

In main.zig, add

const c = @cImport({
    @cInclude("test.h");
});

Then, the C function (here some_func) is not completed following c..

The following content is output to the Zig Language Server output of VS Code.

error: (translate_c): failed zig translate-c command:
C:\Users\Admin\scoop\shims\zig.EXE translate-c --zig-lib-dir C:\Users\Admin\scoop\apps\zig\0.11.0\lib --cache-dir C:\Users\Admin\AppData\Local\Temp\zls -lc --listen=- C:\Users\Admin\AppData\Local\Temp\zls\cimport.h
error:error.Timeout

error: (store ): failed to translate cimport: error.Timeout
debug: (server): Took 57ms to process request-142-textDocument/completion on Thread 20716

I tried changing the zig.buildFilePath option of the extension to ${workspaceFolder}/build/build.zig, but it had no effect.

Everything works fine when I put build.zig in the root directory of the workspace.

Version info:

OS: Windows 11
Zig: 0.11.0
Zls: 0.11.0

Metadata

Metadata

Assignees

Labels

lspIssue with language server integration

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions