Skip to content

Commit

Permalink
core: add missing types to return values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dfxdj authored and bstoeger committed Sep 16, 2024
1 parent cb6766c commit a6a15f9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions core/units.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ struct duration_t : public unit_base<duration_t>
};
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)
{
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>
Expand All @@ -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)
{
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)
{
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)
{
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>
Expand All @@ -181,15 +181,15 @@ struct pressure_t : public unit_base<pressure_t>
};
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)
{
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)
{
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>
Expand All @@ -198,7 +198,7 @@ struct o2pressure_t : public unit_base<o2pressure_t>
};
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>
Expand All @@ -212,7 +212,7 @@ struct temperature_t : public unit_base<temperature_t>
};
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>
Expand All @@ -226,11 +226,11 @@ struct volume_t : public unit_base<volume_t>
};
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)
{
return { .mliter = static_cast<int>(l * 1000) };
return volume_t { .mliter = static_cast<int>(l * 1000) };
}

struct fraction_t : public unit_base<fraction_t>
Expand All @@ -239,11 +239,11 @@ struct fraction_t : public unit_base<fraction_t>
};
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)
{
return { .permille = static_cast<int>(percent * 10) };
return fraction_t { .permille = static_cast<int>(percent * 10) };
}

struct weight_t : public unit_base<weight_t>
Expand Down

0 comments on commit a6a15f9

Please sign in to comment.