0

Note: This is done in RHEL 7.2 with clang 8.0.1.

I'm running the command

clang-tidy test.C -- -I/path/to/header.h

and I get the following error:

1 error generated.
Error while processing test.C.
test.C:28:10: error: 'header.h' file not found [clang-diagnostic-error]
#include "header.h"
         ^
Found compiler error(s).

When I build using g++, it works fine. The above include is the first include statement of the file, and there's some more after it. The file structure is complicated, so it'd be difficult to show where the files are located. I thought the -I argument would find the header, but it doesn't. So, how do I get clang-tidy to find those headers?

helloworld95
  • 366
  • 7
  • 17

1 Answers1

3

Clang tools usually need a compilation database : the compile_commands.json. It provides information required to build your cpp units (g.e the include directories).

You can generate this file from Make, CMake, etc. by using some external tools.

https://github.com/rizsotto/Bear is one of them.

gogoprog
  • 613
  • 4
  • 7