mp-units: Will not compile with -fno-exceptions
I am working on a bare metal ARM-cortex M project using this units library.
I just updated to the head of your main branch and changes in src/core/include/units/magnitude.h
are causing compilation errors. Specifically the use of throw
statements. I have it working now by guarding each throw with the macro
#if __has_feature(cxx_exceptions) || defined(__cpp_exceptions) || \
(defined(_MSC_VER) && defined(_CPPUNWIND)) || \
defined(__EXCEPTIONS)
EDIT:
I think this may not be related to -fno-exceptions
, since it does compile if I make some small code changes. I am trying to fins the root cause and will update/close issue when I find out more (see my comments below).
Compiler: arm-none-eabi-11.3.1-rel1 (latest ARM provided toolchain) arch: ARM-v8M-baseline (M23)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (4 by maintainers)
Commits related to this issue
- Replace compile-time exceptions with terminations This appears to cause problems under `-fno-exceptions` in some rare instances. Should fix #390. — committed to chiphogg/units by chiphogg 2 years ago
@chiphogg, I wouldn’t be surprised if it was the case. For now, I am looking for a final syntax. If it happens that some configurations do not support it, I will introduce the
CONSTEVAL
macro to make it backward compatible. We should always strive to use the best tools where possible and back off only when needed. It will not only improve the quality of the library but also will simplify its possible standardization in the future.https://github.com/mpusz/units/pull/391/commits/70185b49c28ceb856229955f068a8a119f1423f8 should take care of that.
I have posted a PR and kicked off some builds. We’ll see how that goes. Meanwhile, @CrustyAuklet, feel free to try patching in #393 and see if it fixes your issue!
@chiphogg, could you please take a look at this issue?