-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eclipse codan finds interger_quotient ambiguous #219
Comments
Thanks for your interest in the library, and for taking the time to file an issue! I'm also of course always delighted to see the library find use among embedded users. I'm a little confused by the problem description. The formatting has swallowed a couple of the
Here are a couple things that I find confusing.
Are these simply copy-pasted from your editor and/or tooling? I admit I'm a bit stumped as to where they could have come from! Do you have a little more code context you could provide? (For example, the definition of Note, too, that you can try reproducing the problem in Compiler Explorer. If you're able to find a matching compiler and reproduce the error, that would help me fix it. |
In any case, you might be able to work around the problem and satisfy your use case directly with something like the following: uint32_t const prescaler = timer_clock_frequency.coerce_in(au::mega(au::hertz)); This should do the same thing under the hood, as you can see from this Compiler Explorer link: it's just a truncating integer divide by 1,000,000. The reason we say As a bonus, this might also make your intent a little clearer at the callsite. |
First of all, let me state it very clearly: What is causing issues is the code analyzer integrated into Eclipse IDE (CODAN) - here is the link if you need to get a reference: codan - I think of the code analyzer as a smart peer reviewer on my side, warning me about unused variables, wrong types etc. and I have all the checks turned on.
Here some examples:
and this what I get (pasted from the editor - no formatting this time) another example
Here is the original warning message from the editor - no formatting: Again, the library is fine, only I don't like to fill the source code with Thanks again for the attention |
Interesting --- I don't really know what all those numbers mean.
How strange.
Thanks! That makes sense. I'm a big fan of static analysis, and also not a big fan of having to insert a bunch of Unfortunately, I don't expect we'll be able to dig into this any time soon. I'm also not sure what we would be able to do about this even if we could. Maybe the warnings from codan are indicating real opportunities to improve our coding style? Then again, maybe they're just bugs in codan. Units library implementations tend to push C++ templates far beyond what is usual, and sometimes that can expose overly simplistic assumptions in tooling. At any rate, I'm glad that the library itself is working fine! |
Well, I am a new user of the library and, obviously as a newbie, I am facing issues in its use.
I already solved many, but this one I am not.
I am developing for an STM32 microcontroller in the CUBEIDE environment (basically eclipse).
I have all of the CODAN code checks turned on and when performing the integer division between two frequencies in Hertz stored in 32-bits the editor warns against an ambiguous call.
This is the call
uint32_t const prescaler = integer_quotient(timer_clock_frequency, au::hertz(1000000UL));
This is the problem I get:
Problem description: 'integer_quotient' is ambiguous ' Candidates are:
- au::Quantityau::pow,au::Quantity integer_quotient(au::Quantity, au::Quantity)
- au::Quantity<au::hertz,au::quantity<au::pow,unsigned long int>> integer_quotient(au::Quantity, au::Quantity)
I believe some template has a "auto" return type but is called with a partial specialization that confuses the code analyzer, while the compiler, instead does not provide any issue.
Thanks for your attention.
The text was updated successfully, but these errors were encountered: