2

I am working with an old C code base where there are header files with non-standard extensions such as .s, .e, etc instead of .h

For compatibility reasons I cannot rename these files.

Currently these files are causing the following error message in clangd:

Unable to handle compilation, expected exactly one compiler job in ''clang(fe_expected_compiler_job)

Which I interpret as meaning "0 compiler job found" i.e. clangd treats these files as .c source files.

How can I get clangd to treat them as header files ?

Gabriel Devillers
  • 3,155
  • 2
  • 30
  • 53

1 Answers1

0

I found that compile_commands.json can be used to instruct clangd to treat a file with an arbitrary name as a header, using the option to generate a precompiled header file (PCH file):

[
    {
        "directory": "path/to/directory",
        "file": "path/to/file.e",
        "arguments": ["clang", "-x", "c-header", "path/to/file.e"]
    }
]

For a C++ header you would have to use c++-header instead of c-header.

I tested this on clangd 13.0.0.

I got help from this answer.

Gabriel Devillers
  • 3,155
  • 2
  • 30
  • 53