mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
994 stars 79 forks source link

CLion and VSCode not working with v2.2.0 #586

Closed egilll closed 1 week ago

egilll commented 1 week ago

CLion and VSCode appear not to be able to understand any code that uses mp-units version 2.2 or the latest Live At Head. They both however work with version 2.1.

A simple example such as:

quantity dist = 3.4 * si::metre;

shows a "Class Template Argument Deduction failed" error for quantity and a "No viable operator* matches arguments" for *.

Another example, inline constexpr auto kilogram = kilo<gram>; shows "_Cannot substitute arguments for global variable mpunits::si::kilo because of violated constraint PrefixableUnit".

This is only an issue with the IDEs and their code analysis, not an issue with Clang, since I am able to compile and run v2.2 and v2.3 without issue.

I unfortunately can't quite tell why exactly these IDEs aren't able to analyze the code. I'm running CLion 2024.1.2 on Mac, CLion EAP on Mac, and VSCode 1.90.2 on Mac with Clang 18.1.

mpusz commented 1 week ago

Hi @egilll, I do not really know what I can do with this issue.

mp-units library is implemented using valid C++20 code (with some optional C++23 extensions). It is a pity that in 2024, some compilers (i.e., MSVC) and many tools still do not support C++20 correctly.

You can submit such bugs for CLion and VSCode, but I do not believe we can do anything about that here.

egilll commented 1 week ago

Thank you, I mainly wanted to create an issue to inform other users of the library that version 2.1 could still be used by these IDEs, or to see if anyone could think of anything that might be causing this, given that the release seemed to be recent.

Many thanks.

mpusz commented 1 week ago

Well, the library can be openend in any IDE. You will just get lots of red squiggles 😉 But as you said, the compilation, execution, and debugging will work fine.