cpp-best-practices/cmake_template

Build in Visual Studio IDE is broken

Opened this issue · 2 comments

Building intro.exe using Visual Studio IDE (17.8.5) is broken due to warnings emitted by clang-tidy and cppcheck. There are also compile errors involving lefticus::tools. Building on the command line using CMake seems to work.

  1. clang-tidy complains about many missing includes (misc-include-cleaner) in main.cpp:
    image
  2. The compiler (both cl and clang-cl) throws an error when attempting to add an int literal to a lefticus::tools::uint_np8_t:
    image
    image
  3. cppcheck issues warnings (treated as errors) when checking the constexpr tests:
    image

There are other build issues as well, such as Debug builds being broken due to the use of address sanitizer with the -MDd compiler option (see #59). I realize that perhaps building was intended to be done from the command line with this template (as mentioned before, command line builds seem to work), but when developing on windows being able to make use of Visual Studio for editing and running/debugging my code is important. This template should be made compatible with Visual Studio IDE builds.

cblck commented

Having also encountered the reported issues I've submitted pull request #80 which resolves issue 1 by excluding 'misc-include-cleaner' as an error if warnings-as-errors is enabled and issue 3 by adding 'cppcheck-suppress knownConditionTrueFalse' comments to those cases.

Issue 2:
E0349: C++ no operator matches these operands
operand types are: lefticus::tools::uint_np8_t += int
built-in operator+=(<arithmetic>, <promoted arithmetic>) does not match because argument #1 does not match parameter
built-in operator+=(<pointer to object>, <ptrdiff_t>) does not match because argument #1 does not match parameter

As best as I can tell, IntelliSense failing to satisfy the std::integral concept in constexpr int_np &operator+=(const std::integral auto rhs) &noexcept with an int despite the code compiling as expected during the build. Any additional insight anyone can provide would be greatly appreciated.

cblck commented

Issue 2:
I've submitted pull request #81 (wrap external headers in #pragma diag_suppress) and lefticus::tools #8 (move declaration of int_np::value) as a means to suppress the erroneous IntelliSense errors.

The last change, not submitted to lefticus::tools, can be seen here.
I'm hesitant to upstream a change that suppresses IntelliSense warning 349 anywhere non_promoting_ints.hpp is included for a best practices library, but it is good enough hack in my case utilized by changing gh:lefticus/tools#update_build_system to gh:cblck/lefticus-tools#main in Dependencies.cmake.