Is there a way to remove the suggested computer specific path on the suggested llvm-header-guard string when running static analysis with clang-tidy?
For example the suggested header guard for the file (cls/math/matrix.hpp) is: _USERS_NAME_DESKTOP_PROJECT_SRC_CLS_MATH_MATRIX_HPP
But to avoid making this specific to my computer it should only be: _PROJECT_SRC_CLS_MATH_MATRIX_HPP
Is there a way to configure clang-tidy such that it suggests header guards starting from the /project/ directory rather than the /users/ directory?
I am using clang 5.0.0, running from cmake.
I've also had this problem for ages and finally figured it out, at least for public includes: clang-tidy assumes that headers are within a directory called include
.
So, if your headers are like /home/me/myproject/include/myproject/header.h
then it will work properly and recommend MYPROJECT_HEADER_H
. If it doesn't find an include
directory to treat as the root, then it falls back to the absolute path.
So the solution for libraries is to use that structure (which is probably a good idea anyway). I am still not sure about headers inside a project's source though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With