nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
934 stars 134 forks source link

2.3.2 Fails to compile #296

Closed slenius closed 1 year ago

slenius commented 1 year ago

Please include the following information in your issue:

  1. Which version of units you are using 2.3.2
  2. Which compiler exhibited the problem (including compiler version) toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)

2.3.2 Fails to compile, I believe the issue is that mil is defined from inches before inches is defined:

UNIT_ADD(length, foot, feet, ft, unit<std::ratio<381, 1250>, meters>)
UNIT_ADD(length, mil, mils, mil, unit<std::ratio<1000>, inches>)
UNIT_ADD(length, inch, inches, in, unit<std::ratio<1, 12>, feet>)

I believe it should be:

UNIT_ADD(length, foot, feet, ft, unit<std::ratio<381, 1250>, meters>)
UNIT_ADD(length, inch, inches, in, unit<std::ratio<1, 12>, feet>)
UNIT_ADD(length, mil, mils, mil, unit<std::ratio<1000>, inches>)
werdahias commented 1 year ago

@slenius Do you think this is related to #308 ?

slenius commented 1 year ago

It was certainly the ordering of the UNIT_ADD macros, looks like it was fixed here: https://github.com/nholthaus/units/commit/b04d436aaae198939e46194a43ea65b32e44ca6e