2

I have the problem that clang not only checks my code but also 3rd party lib's and automatic generated code for the diagnostic flags which I provided. How can I tell not to do so?

I use catkin-tools and clang to build my c++ project where I use a config file for catkin which provides the cmake args

cmake_args:
# Enable most warnings
- -DCMAKE_CXX_FLAGS=-Werror -Wall -Wextra -Wfloat-equal -isystem=/usr/include/eigen3/

Initially I wanted to add -Wfloat-equal as a diagnostic and the build should fail if it is found somewhere. But while building I found out that there are multiple paths which I need to exclude from the diagnostic check like

 /usr/include/eigen3
 /opt/ros/melodic
 ~/ws/src/devel/

I tried to add /usr/include/eigen3/ as a system header path, but this did not work. So how do I exclude the listed directories ? For clang-tidy I used the .clang-tidy file where I specified the header-filter via a regex

 HeaderFilterRegex: '.*/ws/src/.*'

which works as intended. And for the regex I can also exclude the one sub folder in my ws. Unfortunately the -Wfloat-equal is only part of the clang diagnostics but not of clang-tidy diagnostics

273K
  • 29,503
  • 10
  • 41
  • 64
Westranger
  • 1,308
  • 19
  • 29
  • According to [How to suppress Clang warnings in third-party library header file in CMakeLists.txt file?](https://stackoverflow.com/questions/56707123/how-to-suppress-clang-warnings-in-third-party-library-header-file-in-cmakelists), `-isystem` is the way to do it. You said you tried that but did not give details. Could you show a minimal example that uses `-isystem` but Clang still reports warnings in that directory? – Scott McPeak Jul 14 '22 at 17:44
  • @ScottMcPeak I provided the `DCMAKE_CXX_FLAGS`of my build script and all the folders which I want to "exclude" from the diagnostics in my post. I expect `isystem` to also go throug all subdirectories. E.g I dont want to see any diagnostics from eigen3 so I tried `-isystem=/usr/include/eigen3/` (with and without the last `/`) and `-isystem='eigen3` which both did not work, I still get diagnostics which complains for example about `/usr/include/eigen3/Eigen/src/SVD/JacobiSVD.h` violating `-Wfloat-equal``. Maybe in the next days I can provide a minimal working exmaple to reproduce the error – Westranger Jul 15 '22 at 08:53

0 Answers0