core: add missing types to return values

Fixes build failing on Debian Buster (gcc 8.3.0) with:

/build/subsurface-beta-202409160411/./core/units.h: In function 'duration_t operator""_sec(long long unsigned int)':
/build/subsurface-beta-202409160411/./core/units.h:149:48: error: could not convert '{((int32_t)sec)}' from '<brace-enclosed initializer list>' to 'duration_t'
  return { .seconds = static_cast<int32_t>(sec) };

Signed-off-by: Richard Fuchs <dfx@dfx.at>
This commit is contained in:
Richard Fuchs 2024-09-16 12:38:42 -04:00 committed by bstoeger
parent cb6766c1d4
commit a6a15f9d3a

View file

@ -146,11 +146,11 @@ struct duration_t : public unit_base<duration_t>
}; };
static inline duration_t operator""_sec(unsigned long long sec) static inline duration_t operator""_sec(unsigned long long sec)
{ {
return { .seconds = static_cast<int32_t>(sec) }; return duration_t { .seconds = static_cast<int32_t>(sec) };
} }
static inline duration_t operator""_min(unsigned long long min) static inline duration_t operator""_min(unsigned long long min)
{ {
return { .seconds = static_cast<int32_t>(min * 60) }; return duration_t { .seconds = static_cast<int32_t>(min * 60) };
} }
struct offset_t : public unit_base<offset_t> struct offset_t : public unit_base<offset_t>
@ -164,15 +164,15 @@ struct depth_t : public unit_base<depth_t> // depth to 2000 km
}; };
static inline depth_t operator""_mm(unsigned long long mm) static inline depth_t operator""_mm(unsigned long long mm)
{ {
return { .mm = static_cast<int32_t>(mm) }; return depth_t { .mm = static_cast<int32_t>(mm) };
} }
static inline depth_t operator""_m(unsigned long long m) static inline depth_t operator""_m(unsigned long long m)
{ {
return { .mm = static_cast<int32_t>(m * 1000) }; return depth_t { .mm = static_cast<int32_t>(m * 1000) };
} }
static inline depth_t operator""_ft(unsigned long long ft) static inline depth_t operator""_ft(unsigned long long ft)
{ {
return { .mm = static_cast<int32_t>(round(ft * 304.8)) }; return depth_t { .mm = static_cast<int32_t>(round(ft * 304.8)) };
} }
struct pressure_t : public unit_base<pressure_t> struct pressure_t : public unit_base<pressure_t>
@ -181,15 +181,15 @@ struct pressure_t : public unit_base<pressure_t>
}; };
static inline pressure_t operator""_mbar(unsigned long long mbar) static inline pressure_t operator""_mbar(unsigned long long mbar)
{ {
return { .mbar = static_cast<int32_t>(mbar) }; return pressure_t { .mbar = static_cast<int32_t>(mbar) };
} }
static inline pressure_t operator""_bar(unsigned long long bar) static inline pressure_t operator""_bar(unsigned long long bar)
{ {
return { .mbar = static_cast<int32_t>(bar * 1000) }; return pressure_t { .mbar = static_cast<int32_t>(bar * 1000) };
} }
static inline pressure_t operator""_atm(unsigned long long atm) static inline pressure_t operator""_atm(unsigned long long atm)
{ {
return { .mbar = static_cast<int32_t>(round(atm * 1013.25)) }; return pressure_t { .mbar = static_cast<int32_t>(round(atm * 1013.25)) };
} }
struct o2pressure_t : public unit_base<o2pressure_t> struct o2pressure_t : public unit_base<o2pressure_t>
@ -198,7 +198,7 @@ struct o2pressure_t : public unit_base<o2pressure_t>
}; };
static inline o2pressure_t operator""_baro2(unsigned long long bar) static inline o2pressure_t operator""_baro2(unsigned long long bar)
{ {
return { .mbar = static_cast<uint16_t>(bar * 1000) }; return o2pressure_t { .mbar = static_cast<uint16_t>(bar * 1000) };
} }
struct bearing_t : public unit_base<bearing_t> struct bearing_t : public unit_base<bearing_t>
@ -212,7 +212,7 @@ struct temperature_t : public unit_base<temperature_t>
}; };
static inline temperature_t operator""_K(unsigned long long K) static inline temperature_t operator""_K(unsigned long long K)
{ {
return { .mkelvin = static_cast<uint32_t>(K * 1000) }; return temperature_t { .mkelvin = static_cast<uint32_t>(K * 1000) };
} }
struct temperature_sum_t : public unit_base<temperature_sum_t> struct temperature_sum_t : public unit_base<temperature_sum_t>
@ -226,11 +226,11 @@ struct volume_t : public unit_base<volume_t>
}; };
static inline volume_t operator""_ml(unsigned long long ml) static inline volume_t operator""_ml(unsigned long long ml)
{ {
return { .mliter = static_cast<int>(ml) }; return volume_t { .mliter = static_cast<int>(ml) };
} }
static inline volume_t operator""_l(unsigned long long l) static inline volume_t operator""_l(unsigned long long l)
{ {
return { .mliter = static_cast<int>(l * 1000) }; return volume_t { .mliter = static_cast<int>(l * 1000) };
} }
struct fraction_t : public unit_base<fraction_t> struct fraction_t : public unit_base<fraction_t>
@ -239,11 +239,11 @@ struct fraction_t : public unit_base<fraction_t>
}; };
static inline fraction_t operator""_permille(unsigned long long permille) static inline fraction_t operator""_permille(unsigned long long permille)
{ {
return { .permille = static_cast<int>(permille) }; return fraction_t { .permille = static_cast<int>(permille) };
} }
static inline fraction_t operator""_percent(unsigned long long percent) static inline fraction_t operator""_percent(unsigned long long percent)
{ {
return { .permille = static_cast<int>(percent * 10) }; return fraction_t { .permille = static_cast<int>(percent * 10) };
} }
struct weight_t : public unit_base<weight_t> struct weight_t : public unit_base<weight_t>